📜  如何在 python 代码示例中将数据帧写入 s3 对象

📅  最后修改于: 2022-03-11 14:47:13.136000             🧑  作者: Mango

代码示例1
from io import StringIO # python3; python2: BytesIO 
import boto3

bucket = 'my_bucket_name' # already created on S3
csv_buffer = StringIO()
df.to_csv(csv_buffer)
s3_resource = boto3.resource('s3')
s3_resource.Object(bucket, 'df.csv').put(Body=csv_buffer.getvalue())