how to write a dataframe to s3 object in python

Solutions on MaxInterview for how to write a dataframe to s3 object in python by the best coders in the world

showing results for - "how to write a dataframe to s3 object in python"
Julia
23 Jan 2021
1from io import StringIO # python3; python2: BytesIO 
2import boto3
3
4bucket = 'my_bucket_name' # already created on S3
5csv_buffer = StringIO()
6df.to_csv(csv_buffer)
7s3_resource = boto3.resource('s3')
8s3_resource.Object(bucket, 'df.csv').put(Body=csv_buffer.getvalue())
9
similar questions