I have a pandas DataFrame with a structure like this:
Name Location Position Data1 Data2 Foo loc1 12345 present absent Foo2 loc2 67890 absent present
where Name , Location and Position are MultiIndex levels. However, I need to rename one index level: for this example, I need to change Foo2 to Bar .
I thought DataFrame.rename() would do the job, however, if I specify
new_df = old_df.rename(index={"Foo2": "Bar"})
it really does not change the index, and, even worse, it aligns it.
Is this what I want to do? Or do I find a pandas error?
source share