Skip to content

Commit 5cde722

Browse files
committed
fix test cases which assumed mangled nans
1 parent 33e1689 commit 5cde722

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

pandas/tests/base/test_value_counts.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,5 +287,5 @@ def test_value_counts_with_nan(dropna, index_or_series):
287287
if dropna is True:
288288
expected = Series([1], index=[True])
289289
else:
290-
expected = Series([2, 1], index=[pd.NA, True])
290+
expected = Series([1, 1, 1], index=[True, pd.NA, np.nan])
291291
tm.assert_series_equal(res, expected)

pandas/tests/libs/test_hashtable.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -462,13 +462,10 @@ def test_mode_stable(self, dtype, type_suffix, writable):
462462

463463

464464
def test_modes_with_nans():
465-
# GH39007
466-
values = np.array([True, pd.NA, np.nan], dtype=np.object_)
467-
# pd.Na and np.nan will have the same representative: np.nan
468-
# thus we have 2 nans and 1 True
465+
# GH42688, nans aren't mangled
466+
values = np.array([True, pd.NA, np.nan, pd.NA, np.nan], dtype=np.object_)
469467
modes = ht.mode(values, False)
470-
assert modes.size == 1
471-
assert np.isnan(modes[0])
468+
assert modes.size == 2
472469

473470

474471
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)