大家下午好,
我正在尝试将多个数据帧保存到不同工作表上的 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:[Errno 2]没有这样的文件或目录:'s3://sagemaker-bucket-xxxx/xxxx/xxxx/Provider Data.xlsx'
最佳答案
s3 不是一个标准文件系统,您可以使用不知道数据位置不同接口(interface)的框架(例如 Pandas)来读写它。
最简单的方法是将其本地写入笔记本实例的文件系统,然后运行 aws s3 cp
将其上传到 s3。
关于python - 在 Excel 工作簿上保存多个数据帧,然后上传到 AWS S3 存储桶,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56031922/