Save Pandas data frame to S3
- bdata3
- Jul 5, 2020
- 1 min read
Well sometimes it just works when having the s3 as the destination but the following worked even when the above didn't:
from io import StringIO import boto3
import pandas as pd
df = pd.DataFrame([[1,2],[3,4]],['a','b']) csv_buffer = StringIO() df.to_csv(csv_buffer,index=False) s3_resource = boto3.resource('s3') s3_resource.Object(bucket, 'df.csv').put(Body=csv_buffer.getvalue())

Comments