Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions pandas/tests/arrays/categorical/test_analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,13 @@ def test_min_max_with_nan(self, skipna):

@pytest.mark.parametrize("function", ["min", "max"])
@pytest.mark.parametrize("skipna", [True, False])
def test_min_max_only_nan(self, function, skipna):
@pytest.mark.parametrize("box_in_series", [True, False])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CategoricalIndex, DataFrame col?

Copy link
Member

@jorisvandenbossche jorisvandenbossche Apr 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are Series tests elsewhere for Categorical min/max, eg the previous PR that touched the Categorical.min/max implementation added the Series tests in reductions/test_reductions.py: 37526c1, so I would update the tests there instead of here in this file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jorisvandenbossche Do you mean do that instead of what I'm doing here, or rather that CategoricalIndex and DataFrame cases should be added to test_reductions.py instead of here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes the point is to do these in test_reductions.py, adding a similiar missing categorical test there

def test_min_max_only_nan(self, function, skipna, box_in_series):
# https://github.com/pandas-dev/pandas/issues/33450
cat = Categorical([np.nan], categories=[1, 2], ordered=True)
result = getattr(cat, function)(skipna=skipna)
arr = Categorical([np.nan], categories=[1, 2], ordered=True)
if box_in_series:
arr = Series(arr)
result = getattr(arr, function)(skipna=skipna)
assert result is np.nan

@pytest.mark.parametrize("method", ["min", "max"])
Expand Down