Created
February 28, 2019 15:58
-
-
Save yassineAlouini/384d4fafedadd8b78685aafc82952354 to your computer and use it in GitHub Desktop.
Save DataFrame to S3 as a CSV with bz2 compression
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import s3fs | |
import pandas as pd | |
import bz2file | |
s3 = s3fs.S3FileSystem() | |
df = pd.DataFrame() # Replace with your DataFrame | |
dest_s3_key = "" # Where to save in S3 | |
with s3.open(dest_s3_key, 'wb') as dest_file: | |
with bz2file.open(dest_file, 'wb') as compressed_file: | |
df.to_csv(compressed_file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment