Grouping by Multi-Indices of both Row and Column
I have created a table using Pandas following material from here.
The table created makes use of Multi-Indices for both columns and rows.
I am trying to compute the descriptive statistics for each year and subject, meaning, displaying for instance the mean of 2013 for Bob, the mean for 2013 for Guido, and the mean for 2013 for Sue, for all subjects, and for all years. The means for Bob would consider the means for HR and Temp. Note: The types are the same as a coincidence, as this is not the case for the table implemented. Other subjects not included in the screenshot have varying types.
The closest I have managed to come to the solution is through the following code df.groupby(level = 0, axis = 0).describe()
. This grouped the data by the year, however, did not group by subject also.
Category Data Science