Skip to content

Commit 0966b81

Browse files
committed
fix test cases which assumed mangled nans
1 parent 0c0ab28 commit 0966b81

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
@@ -281,5 +281,5 @@ def test_value_counts_with_nan(dropna, index_or_series):
281281
if dropna is True:
282282
expected = Series([1], index=[True])
283283
else:
284-
expected = Series([2, 1], index=[pd.NA, True])
284+
expected = Series([1, 1, 1], index=[True, pd.NA, np.nan])
285285
tm.assert_series_equal(res, expected)

pandas/tests/libs/test_hashtable.py

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

454454

455455
def test_modes_with_nans():
456-
# GH39007
457-
values = np.array([True, pd.NA, np.nan], dtype=np.object_)
458-
# pd.Na and np.nan will have the same representative: np.nan
459-
# thus we have 2 nans and 1 True
456+
# GH42688, nans aren't mangled
457+
values = np.array([True, pd.NA, np.nan, pd.NA, np.nan], dtype=np.object_)
460458
modes = ht.mode(values, False)
461-
assert modes.size == 1
462-
assert np.isnan(modes[0])
459+
assert modes.size == 2
463460

464461

465462
def test_unique_label_indices_intp(writable):

0 commit comments

Comments
 (0)