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 get row index of matching row in column 0 Sri 7 644 Apr-10-2019, 08:26 PM
Last Post: perfringo
  Openpyxl -Coming up with a single column from a multi column data set Givan007 1 660 Sep-07-2018, 04:29 AM
Last Post: Prabakaran141
  Add column to csv file based on values in existing column Irah 3 2,361 Dec-22-2017, 12:05 PM
Last Post: Larz60+
  finding rows with one column distinct and the other column different python_enthusiast 0 1,116 Jul-14-2017, 08:15 PM
Last Post: python_enthusiast

Forum Jump:

Users browsing this thread: 1 Guest(s)