Store Excel file exported from Pandas in AWS
Taken from here: Write to StringIO object using Pandas Excelwriter?
You can dump the 'output' to S3
# Note, Python 2 example. For Python 3 use: output = io.BytesIO().
output = StringIO.StringIO()
# Use the StringIO object as the filehandle.
writer = pd.ExcelWriter(output, engine='xlsxwriter')
To add to balderman's answer, the complete code for getting it to S3 would be
import io
import pandas as pd
import boto3
# ...
# make data frame 'df'
with io.BytesIO() as output:
with pd.ExcelWriter(output, engine='xlsxwriter') as writer:
df.to_excel(writer)
data = output.getvalue()
s3 = boto3.resource('s3')
s3.Bucket('my-bucket').put_object(Key='data.xlsx', Body=data)
See also the XlsxWriter documentation.