How to Remove Index Column While Saving CSV in Pandas
Last Updated :
24 Apr, 2025
In this article, we'll discuss how to avoid pandas creating an index in a saved CSV file. Pandas is a library in Python where one can work with data. While working with Pandas, you may need to save a DataFrame to a CSV file. The Pandas library includes an index column in the output CSV file by default. Further in the article, we'll understand the default behavior and find a solution if we don't want the index in the output of our saved CSV.
Remove Index Column While Saving CSV in Pandas
Below are the ways by which we can avoid pandas creating an index in a saved CSV in Python:
- Pandas to CSV without index
- Pandas to CSV without index and header
- Pandas to CSV without header
- Pandas to CSV by dropping index
Pandas to CSV Without Index
In this example, we are removing the index column directly. The output will be saved in the output.csv file in which the index will be dropped.
Python3
import pandas as pd
data = {'Names': ['Sanjana', 'Deepthi', 'Sankeerthana']}
age = ['17', '22', '33']
df = pd.DataFrame(data, index=age)
print(df)
df.to_csv('output.csv', index=False)