I am trying to divide the dataframe like below:
from io import StringIO
import pandas as pd
data = """
A,B,C
87jg,28,3012
h372,28,3011
kj87,27,3011
2yh8,54,3010
802h,53,3010
5d8b,52,3010
"""
df = pd.read_csv(StringIO(data), sep=',')
for key, group in df.groupby(['C','B']):
group.to_csv(f'df_{key}.csv', index=False)
This would export the results of group by dataframes to local machine. Is there a way to perform this operation and upload these multiple split csv's to s3 (something like put_object of boto3)