I'm given a dataframe, to which I wish to add a title on the indexing column. I've done this:
test_set = pd.read_csv('test_set.csv')
df= pd.DataFrame(data = test_set)
df.to_csv('test_set2.csv', encoding='utf-8')
df.index.rename('indexTitle', inplace=True)
If I print this test_set now, it's got the title on the index column. But in the end the file doesn't display with the title; the change isn't saved in the file. I know I can add the title manually but would like to know if there's a way to do so through my code.
It prints this:
data
indexTitle
0 data0...
1 data1...
2 data2...
...
I'm using Python 2.7, pandas 0.22