Search⌘ K

Export Pandas DataFrame to CSV Format

Explore how to export pandas DataFrames to CSV files, understand the role of the DataFrame index, and learn how to use the index parameter to include or exclude it in your CSV exports.

We'll cover the following...

Try it yourself

Try executing the code below to see the result.

Python 3.8
import pandas as pd
df = pd.DataFrame([[1, 2], [3, 4]], columns=['x', 'y'])
print(df.to_csv())

Explanation

What’s going on in the unnamed column with 0 and 1 values?

The ...