Skip to content

Commit e8edcea

Browse files
committed
fixed test_masked.py
1 parent bf6aaef commit e8edcea

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

pandas/tests/extension/test_masked.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ class TestMaskedArrays(base.ExtensionTests):
171171
@pytest.mark.parametrize("na_action", [None, "ignore"])
172172
def test_map(self, data_missing, na_action):
173173
result = data_missing.map(lambda x: x, na_action=na_action)
174+
if data_missing.dtype.kind != "b":
175+
for i in range(len(result)):
176+
if result[i] is pd.NA:
177+
result[i] = "nan"
178+
result = result.astype("float64")
179+
174180
if data_missing.dtype == Float32Dtype():
175181
# map roundtrips through objects, which converts to float64
176182
expected = data_missing.to_numpy(dtype="float64", na_value=np.nan)
@@ -181,10 +187,15 @@ def test_map(self, data_missing, na_action):
181187
def test_map_na_action_ignore(self, data_missing_for_sorting):
182188
zero = data_missing_for_sorting[2]
183189
result = data_missing_for_sorting.map(lambda x: zero, na_action="ignore")
190+
184191
if data_missing_for_sorting.dtype.kind == "b":
185192
expected = np.array([False, pd.NA, False], dtype=object)
186193
else:
187194
expected = np.array([zero, np.nan, zero])
195+
for i in range(len(result)):
196+
if result[i] is pd.NA:
197+
result[i] = "nan"
198+
result = result.astype("float64")
188199
tm.assert_numpy_array_equal(result, expected)
189200

190201
def _get_expected_exception(self, op_name, obj, other):

0 commit comments

Comments
 (0)