Topics in this subject
Pandas 1 min read Updated 4 Aug 2026

3. Writing Data

df.tocsv('out.csv', index=False) # drop the index column

df.to_csv('out.csv', index=False)         # drop the index column
df.to_excel('out.xlsx', sheet_name='Data', index=False)
df.to_json('out.json', orient='records')  # list of row dicts
df.to_sql('table', conn, if_exists='replace', index=False)
df.to_parquet('out.parquet')

⚠️ Common Mistake: Forgetting index=False writes an extra unnamed index column into your CSV.

💡 Tip: orient='records' gives the JSON shape most web APIs expect: [{...}, {...}].