• Post author:
  • Post category:Pandas
  • Post last modified:May 27, 2024
  • Reading time:6 mins read
You are currently viewing Export Pandas to CSV without Index & Header

In order to export Pandas DataFrame to CSV without an index (no row indices) use param index=False and to ignore/remove header use header=False param on to_csv() method. In this article, I will explain how to remove the index and header on the CSV file with examples. Note that this method also supports several other parameters to write Pandas DataFrame to CSV file.


Pandas to CSV without Index & Header

By default exporting a Pandas DataFrame to CSV includes column names on the first row, row index on the first column, and writes a file with a comma-separated delimiter to separate columns. Pandas.DataFrame.to_csv() method provides parameters to ignore an index and header while writing.

To run some examples of exporting pandas to CSV without index & header, let’s create a Pandas DataFrame.

# Create a DataFrame
import pandas as pd
import numpy as np
technologies = {
    'Fee' :[22000,25000,np.nan,24000],
df = pd.DataFrame(technologies)
print("Create DataFrame:\n", df)

Yields below output.

pandas csv without index

Pandas to CSV with no Index

You can export a Pandas DataFrame to a CSV file without including the index by using the index=False parameter in the to_csv() method. This allows you to exclude the index when writing or exporting the DataFrame to a CSV file.

# Remove column header and index

Writes courses.csv file without index.

# Output:

Pandas to CSV without Header

To write DataFrame to CSV without a column header (remove column names) use header=False param on to_csv() method.

# Remove header while writing

Writes courses.csv file as.

# Output:

Export without Index and Header

Let’s combine these and see how you can use both removing index and column names on the CSV files.

# Remove header & index while writing
df.to_csv("c:/tmp/courses.csv",header=False, index=False)


In this quick article, I have explained remove the header without column names and index while writing DataFrame to a CSV file. Use param header=False to remove columns and use index=False to remove index (no row indices) on to_csv() method.

Happy Learning !!


Leave a Reply