Search code examples
pythonpandasamazon-s3parquet

Store Pandas Dataframe to S3 with Secret Key


How do we store a dataframe to S3 using our secret key in parquet format? What parameters can I add to the below code?

filename=file_name+'.parquet'
df.to_parquet('s3://path/'+filename)

Parameters/Logic for using Secret Key while storing parquet file to S3


Solution

  • you can use your access credentiels as headers in the storage_options a option for the to_praquet

    like this :

    s3_storage_options = {
        'key': 'acces_key',
        'secret': 'secret_key'
    }
    df.to_parquet('s3://bucket_name/file_name.parquet', storage_options=s3_storage_options)