Python • Pandas • Conversions
Keep all conversion snippets on one page so you can jump to the exact format you need. Use the anchor links or copy the ready-to-run code blocks below.
The most searched conversion. Mind delimiter, encoding, and whether you want the index column.
import pandas as pddf = pd.read_parquet("input.parquet")# UTF-8 with comma delimiter (default)df.to_csv("output.csv", index=False, encoding="utf-8")# Custom delimiter & compressiondf.to_csv("output.tsv.gz",sep="\t",index=False,compression="gzip",encoding="utf-8",)
Tip: For large exports, write to gzip or bz2 to reduce file size; most tools can read compressed CSV directly.
Choose the orientation that matches your downstream consumer.records is usually best for APIs.
import pandas as pddf = pd.read_parquet("input.parquet")# Records (list of objects) for APIsdf.to_json("output.json", orient="records", lines=False)# Line-delimited JSON for streaming/BigQuerydf.to_json("output.ndjson", orient="records", lines=True)
Tip: If you see bytes objects, set df.convert_dtypes() before export to normalize types.
Great for sharing smaller slices of data. Keep row counts modest—Excel struggles beyond ~1M rows.
import pandas as pddf = pd.read_parquet("input.parquet")with pd.ExcelWriter("output.xlsx", engine="xlsxwriter") as writer:df.to_excel(writer, sheet_name="data", index=False)
Tip: For multiple sheets, call to_excel repeatedly with different sheet_name while reusing the same writer instance.
encoding="utf-8" when writing CSV with non-ASCII characters.read_parquet and consider chunked writes for very large datasets. convert_dtypes() to normalize nullable types before export. df[["colA", "colB"]] before writing to guarantee consistent schemas.