如何将已完成的Pandas移到excel文件或googlesh文件中

2024-10-03 19:23:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经完成了一些熊猫的编码,但我不知道现在该怎么办。我想导出熊猫到谷歌表或excel文件,这样我就可以用googledatastudio图表的数据出来。由于我是熊猫新手,有人知道如何将完成的熊猫移到excel或googlesheets文件中吗?你知道吗

我试着用所有的关键词和整个问题来搜索答案!最接近的结果是: cp:无法创建常规文件“drive/My drive/”:没有这样的文件或目录

Finished_Data.to_csv('Completed_Data.csv')
!cp Completed_Data.csv drive/My\ Drive/

我尝试的大多数方法都没有给我任何结果,只是浪费了我的时间。你知道吗


Tags: 文件csv数据编码datamy图表drive
1条回答
网友
1楼 · 发布于 2024-10-03 19:23:36

如果您只想创建一个excel文件,可以使用pandas.to\u excel: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.to_excel.html

更新

what’s the best way to save pd.dataframe object as a google sheet document

googlesheets提供了一个API。我对它不熟悉,但它似乎有很好的记录 https://developers.google.com/sheets/api/quickstart/python

Is there something wrong with my code? export_excel = Finished.to_excel (r'C:\Users\Person\Desktop\Finished Pandas.xlsx', index = None, header=True)

  1. excel不会返回任何内容。你不需要把它赋给一个变量

  2. 索引是一个布尔参数。如果希望导出索引,请将其设置为True;否则,请将其设置为False。 xlsx还依赖于库openpyxl。你收到什么错误信息

相关问题 更多 >