I have the following dataframe in pandas (python):
B. X. Y.
A
alpha 3. 5. 5
beta 9. 9. 11
I want to change 'alpha' for another name, like 'mu'. What should I do?
rename() function is used to alter Series index labels or name for the given Series object. inplace : Whether to return a new Series. If True then value of copy is ignored. level : In case of a MultiIndex, only rename labels in the specified level.
Use rename
with parameter index
pass a dictionary to the index
parameter
df.rename(index={'alpha': 'mu'})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With