Skip to content
Advertisement

Python : get access to a column of a dataframe with multiindex

Let’s say that I have this dataframe with multi index :

JavaScript

How do we get access to the data in the columns “Balance” or “Date”, I do not get why that does not work :

JavaScript

or

JavaScript

Advertisement

Answer

You should use Index.get_level_values:

JavaScript

You can pass labels :

JavaScript

OR:

Pass indices:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement