Backtick Knowledge Base
  • Backtick Knowledge Base
  • 📊Statistics
    • Kernel Density Estimation
    • Tests
  • 🍂Machine Learning
    • Fit and predict
    • Encoding
    • Feature Scaling
    • Pipeline
    • Model Evaluation & Selection
      • The Bias-Variance Decomposition
      • Kullback–Leibler Divergence
      • AIC & BIC
      • Cross-Validation
    • Feature Selection
    • Dimensionality Reduction
    • Clustering
    • Pandas
  • 🧠Deep Learning
  • 🐍Python
    • Beautiful Data
    • S3
      • List bucket items
      • Delete bucket items
      • Get objects
      • Upload objects
      • Get files
      • Upload files
      • Read .csv-file to dataframe
      • Write dataframe to .csv-file
  • ☁️Cloud
    • GCP
    • AWS
      • Users & Policies
        • Basic setup
        • MFA
      • EKS
        • Setup
        • Kube Config
        • Dashboard
      • S3
        • Copying buckets
  • ❖ Distributed Computing
    • Map-Reduce
    • Spark
    • Dask
  • ⎈ Kubernetes
Powered by GitBook
On this page
  • Pandas dataframe
  • Dask dataframe

Was this helpful?

  1. Python
  2. S3

Write dataframe to .csv-file

Write dataframe to a .csv-file in an S3 bucket

Pandas dataframe

The following code writes a pandas dataframe to a .csv-file in an S3 bucket

import pandas as pd
import s3fs

key = 'key_name'    # name of key
bucket = 'bucket_name'    # name of bucket

# write pandas dataframe 'df' to a .csv-file in an S3-bucket
df.to_csv('s3://{}/{}'.format(bucket, key))

Dask dataframe

The following code writes a dask dataframe to a .csv-file in an S3 bucket

import dask.dataframe as dd

key = 'key_name'    # name of key
bucket = 'bucket_name'    # name of bucket

# write dask dataframe 'ddf' to a .csv-file in an S3-bucket
ddf.to_csv('s3://{}/{}'.format(bucket, key))
PreviousRead .csv-file to dataframeNextGCP

Last updated 5 years ago

Was this helpful?

🐍