How to remove serial number from exported csv file in Python?

python

#1

Hi,

I am exporting a pandas dataframe using below code.

test.to_csv("C:/Users/Steve/Desktop/first.csv", columns=['datetime','count'])

In above code, you can see that I want to export only two columns “datetime” and “count” but in output file it has three columns. One additional for serial number.

Please help me to remove this serial number column from output file.

Regards,
Steve


#2

@Steve,

You can use “index=False” as an additional argument to remove the serial number from output csv file.

Regards,
Sunil