Closed
Description
When passing a level
argument and numeric_only=True
to max
and min
, non-numeric columns are not dropped in the result:
>>> df = pd.DataFrame({'a': [1,1,2,2], 'b': [1,4,2,6],
'c': [6,3,2,3], 'd': ['w','x','y','z']})
>>> df.set_index(['a', 'b'])
>>> df
c d
a b
1 1 6 w
4 3 x
2 2 2 y
6 3 z
>>> df.max(level=0, numeric_only=True)
c d
a
1 6 x
2 3 z
I would have expected that column 'd' would not be included here, as is the case if the level
argument is omitted:
>>> df.max(numeric_only=True)
c 6
dtype: int64