一种将pandas数据帧转换为tableau提取的快速简便方法。
pandleau的Python项目详细描述
潘德鲁
一种快速简便的方法,将pandas数据帧转换为tableau.tde或.hyper extract。
开始
先决条件
- 如果要输出为.tde格式,则需要直接从tableau的站点here安装tableaudk。
- 如果要输出为.hyper格式,则需要直接从Tableau的站点here安装Extract API 2.0。
- 尽管tableau的网站声称不支持python 3,但该模块经过测试可以在python3.6上完全正常工作。
安装
安装tableausdk完成后,下载此存储库,导航到下载文件并在cmd或terminal中运行以下命令:
python -m setup.py install
您也可以使用pip:
pip install pandleau
但请注意,这将引发一个警告,提示您在系统必备中使用上述链接安装tableaudk。
示例
在本例中,我从kaggle获取了以下巴西航班数据:https://www.kaggle.com/microtang/exploring-brazil-flights-data/data。
importpandasaspdfrompandleauimport*# Import the dataexample_df=pd.read_csv(r'example/BrFlights2.csv',encoding='iso-8859-1')# Format dates in pandasexample_df['Partida.Prevista']=pd.to_datetime(example_df['Partida.Prevista'],format='%Y-%m-%d')example_df['Partida.Real']=pd.to_datetime(example_df['Partida.Real'],format='%Y-%m-%d')example_df['Chegada.Prevista']=pd.to_datetime(example_df['Chegada.Prevista'],format='%Y-%m-%d')example_df['Chegada.Real']=pd.to_datetime(example_df['Chegada.Real'],format='%Y-%m-%d')# Set up a spatial columnexample_df.loc[:,'SpatialDest']=example_df['LongDest'].apply(lambdax:"POINT ("+str(round(x,6)))+ \ example_df['LatDest'].apply(lambdax:" "+str(round(x,6))+")")# Change to pandleau objectdf_tableau=pandleau(example_df)# Define spatial columndf_tableau.set_spatial('SpatialDest',indicator=True)# Write .tde or .hyper Extract!df_tableau.to_tableau('test.hyper',add_index=False)
Tableau服务器/在线自动化
EricChan(erickhchan)写了一篇非常酷的博客文章,内容是在将数据推送到Tableau Online(Tableau服务器的SaaS版本)之前,使用Python混合和清理数据。这是学习如何使用tableau server client和pandleau自动执行数据刷新过程的好方法。在这里查看他的博客文章:https://www.erickhchan.com/data/2019/03/18/python-tableau-server.html
作者
- benjamin wiley-jamin4lyfe
- zhiri(jerry)wang-zhiruiwang
- aaron wiegel-aawiegel
- pointy闪亮燃烧-PointyShinyBurning
- harrison-harrison-h
相关项目
RTableau使用pandleau将r data.frame转换为tableau extract
许可证
这个项目是在麻省理工学院的许可下授权的-请参见LICENSE.md文件了解详细信息