Skip to content
7 changes: 7 additions & 0 deletions pandas/tests/series/methods/test_replace.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ def test_replace_with_dict_with_bool_keys(self):
expected = pd.Series(["yes", False, "yes"])
tm.assert_series_equal(result, expected)

@pytest.mark.parametrize("dtype", ["int8", "int16", "int32", "int64"])
Copy link
Member

Choose a reason for hiding this comment

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

the types need to be capitalised, as in the issue, e.g. Int64 not int64

def test_replace_int_with_na(self, dtype):
Copy link
Contributor

Choose a reason for hiding this comment

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

should use any_nullable_int_dtype fixture here

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd call it test_replace_nullable_int_with_na or test_replace_Int_with_na

# GH 38267
result = pd.Series([0, None]).astype(dtype).replace(0, pd.NA)
Copy link
Contributor

Choose a reason for hiding this comment

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

pass dtype directly to the Series constructor

expected = pd.Series([0, None]).astype(dtype).fillna(0).replace(0, pd.NA)
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to construct expected directly (e.g. expected = pd.Series([pd.NA, pd.NA]))?

tm.assert_series_equal(result, expected)

def test_replace2(self):
N = 100
ser = pd.Series(np.fabs(np.random.randn(N)), tm.makeDateIndex(N), dtype=object)
Expand Down