在 colaboratary 中将熊猫数据框导出到谷歌驱动器

1 python-3.x pandas google-drive-api google-colaboratory

sentmaildt1 = seriessplit(sentmail,'Sent_date',('sentmail_date','sentmail_time')," ")

sentmaildt1.to_csv("sentmaildt1.csv", columns = sentmaildt1.columns)

from google.colab import files

files.download('sentmaildt1.csv')
Run Code Online (Sandbox Code Playgroud)

我对我的 sendmail 数据帧(400 万 x 5)进行了基本操作,并将其存储在其他数据帧 sentmaildt1 中。现在我想在 csv 中获取它并下载到本地系统。出现以下错误:

错误:无法下载:

我希望这个 csv 转到我链接的谷歌驱动器。我使用 pydrive 从驱动器读取所有 csv 文件。我也想在那里存储输出。

小智 5

如果要将 DataFrame 保存到 Google Drive:

df.to_csv("example.csv")
uploaded = drive.CreateFile({'title': 'name.csv'})
uploaded.SetContentFile("example.csv")
uploaded.Upload()
print('Uploaded file with ID {}'.format(uploaded.get('id')))}
Run Code Online (Sandbox Code Playgroud)

如果要将其下载到本地系统:

df.to_csv("example.csv")
files.download()
Run Code Online (Sandbox Code Playgroud)