Home > Net >  When I create a csv, from a data frame in Python, a new column is added to the beginning of the tabl
When I create a csv, from a data frame in Python, a new column is added to the beginning of the tabl

Time:11-04

CSV Table

How do I remove the first column in the table below, in Python, which is created when I generate a csv from a data frame in Python? Or is there a way to prevent this first column from being created in the first place.

CodePudding user response:

When you use pandas.to_csv(), there is the index param setted True by default. This means that it will write a column for the index.

If you want to prevent index writing, you have to set it to false:

df.to_csv(your_path, index=False)
  • Related