Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to define index column name using df.to_csv
I have dataframe, and I want to write to csv. But when write to csv, the first column name disaaper (which is Index)

Before write,
Index c1 c2
A 2 5
B 5 9

I use below command,
when I open csv file, data look like:

       c1 c2
A      2  5
B      5  9
how can rename the index column name? to look like my data:

Names c1 c2
A      2  5
B      5  9

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  how to retain time format in df.to_csv Mekala 2 297 Aug-07-2020, 07:04 AM
Last Post: buran
  Assigning Column nunique values to another DataFrame column Pythonito 1 260 Jun-26-2020, 06:52 AM
Last Post: hussainmujtaba
  How get row index of matching row in column 0 Sri 7 933 Apr-10-2019, 08:26 PM
Last Post: perfringo
  Openpyxl -Coming up with a single column from a multi column data set Givan007 1 941 Sep-07-2018, 04:29 AM
Last Post: Prabakaran141
  Add column to csv file based on values in existing column Irah 3 2,831 Dec-22-2017, 12:05 PM
Last Post: Larz60+

Forum Jump:

Users browsing this thread: 1 Guest(s)