1
votes

I have following pandas dataframe. How can I access subcolumns of this dataframe and plot them (eg. plotting distribution of min values using boxplot)

I am using following python statement but I am not getting the output.

df.boxplot(column=['score']['min'])

enter image description here

1

1 Answers

0
votes

Since it's a multi-level column you have to pass it as a tuple. To read more indexing multi-level structure go through pandas doc MultiIndex / advanced indexing.

df.boxplot(column=[('score', 'min')])

Or, use df.xs, in this case return type is Series, to boxplot Series use Series.plot.box.

df.xs(('score', 'min')).plot.box()