Is there a way to rename an index in a multi-index data frame?
Example
import pandas as pd
df = pd.DataFrame([
['green','M', 10.1, 'class2'],
['red', 'L', 13.5, 'class1']])
df.columns = ['color', 'size', 'price', 'classifier']
df.set_index(['color','size'], inplace=True)
Gives
price classifier
color size
green M 10.1 class2
red L 13.5 class1
I want to rename the index 'size' to become size_modified
df.rename(index={'size': 'Size_Mod'}, inplace=True)
didn't work