在Excel工作簿上保存多个数据框,然后上传到AWS S3存储桶

时间:2019-05-08 00:09:53

标签: python excel pandas amazon-s3 amazon-sagemaker

大家下午好

我正在尝试将多个数据框保存到不同工作表上的excel工作簿中。然后将该工作簿上传到Amazon S3存储桶。下面的代码以99%的方式工作,但是writer.save()在我的S3存储桶上找不到我的excel文件。如果您知道解决方法,请协助。谢谢。

#Exports the data back to Excel - PLEASE READ LINE BELOW THIS CODE
bucket='sagemaker-bucket-xxxx/xxxx/xxxxx'
data_key = 'Provider Data.xlsx'
data_location = 's3://{}/{}'.format(bucket, data_key)
writer = pd.ExcelWriter(data_location) #Targets the file where data is to be sent to
Comparison.to_excel(writer,'DATA') #Targets the worksheet data is to be sent too
df_current.to_excel(writer,'New Records') #Targets the worksheet data is to be sent too
df_prev.to_excel(writer,'Old Records') #Targets the worksheet data is to be sent too
df_same.to_excel(writer,'Same Records') #Targets the worksheet data is to be sent too
ALLCOUNT.to_excel(writer,'RPN Roll Up Count') #Targets the worksheet data is to be sent too
writer.save() #Saves files

错误消息在下面列出。

FileNotFoundError:[错误2]没有此类文件或目录:'s3:// sagemaker-bucket-xxxx / xxxx / xxxx / Provider Data.xlsx'

1 个答案:

答案 0 :(得分:0)

s3不是可以在不知道数据位置不同接口的框架(例如Pandas)中读写的标准文件系统。

最简单的方法是将其本地写入笔记本实例的文件系统,然后运行aws s3 cp将其上传到s3。