Reputation: 147
I have created a dataframe (df) as below:
I want to change the index of my dataframe as below without changing the values
I tried setindex , reindex but not getting the desired result.
Thanks in advance
Upvotes: 0
Views: 108
Reputation: 5757
You can set index as shown below
>>> idx = pd.Index(['s7', 's8', 's9', 's10', 's11'])
>>> idx
Index(['s7', 's8', 's9', 's10', 's11'], dtype='object')
>>> df.set_index(idx)
Height Weight
s7 167 108
s8 107 180
s9 134 187
s10 147 176
s11 160 198
>>>
Upvotes: 1