-
-
Notifications
You must be signed in to change notification settings - Fork 19.3k
Closed
Closed
Copy link
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsNuisance ColumnsIdentifying/Dropping nuisance columns in reductions, groupby.add, DataFrame.applyIdentifying/Dropping nuisance columns in reductions, groupby.add, DataFrame.applyReduction Operationssum, mean, min, max, etc.sum, mean, min, max, etc.
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
Metadata
Metadata
Assignees
Labels
BugDtype ConversionsUnexpected or buggy dtype conversionsUnexpected or buggy dtype conversionsNuisance ColumnsIdentifying/Dropping nuisance columns in reductions, groupby.add, DataFrame.applyIdentifying/Dropping nuisance columns in reductions, groupby.add, DataFrame.applyReduction Operationssum, mean, min, max, etc.sum, mean, min, max, etc.