Skip to content

TST: Inconsistent behavior of .replace() in Int64 series with NA #38693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Dec 28, 2020
9 changes: 9 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,15 @@ def test_replace_with_dict_with_bool_keys(self):
expected = pd.Series(["yes", False, "yes"])
tm.assert_series_equal(result, expected)

def test_replace_Int_with_na(self, any_nullable_int_dtype):
# GH 38267
result = pd.Series([0, None], dtype=any_nullable_int_dtype).replace(0, pd.NA)
expected = pd.Series([pd.NA, pd.NA], dtype=any_nullable_int_dtype)
tm.assert_series_equal(result, expected)
result = pd.Series([0, 1], dtype=any_nullable_int_dtype).replace(0, pd.NA)
result.replace(1, pd.NA, inplace=True)
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