Skip to content

Commit 1f218b6

Browse files
updates for 2.3
1 parent 7303b12 commit 1f218b6

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

pandas/tests/frame/methods/test_replace.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ def test_regex_replace_dict_nested_non_first_character(
297297
expected = DataFrame({"first": [".bc", "bc.", "c.b"]}, dtype=dtype)
298298
tm.assert_frame_equal(result, expected)
299299

300-
@pytest.mark.xfail(using_string_dtype(), reason="can't set float into string")
301300
def test_regex_replace_dict_nested_gh4115(self):
302301
df = DataFrame({"Type": ["Q", "T", "Q", "Q", "T"], "tmp": 2})
303302
expected = DataFrame({"Type": [0, 1, 0, 0, 1], "tmp": 2})
@@ -556,7 +555,6 @@ def test_replace_series_dict(self):
556555
result = df.replace(s, df.mean())
557556
tm.assert_frame_equal(result, expected)
558557

559-
@pytest.mark.xfail(using_string_dtype(), reason="can't set float into string")
560558
def test_replace_convert(self):
561559
# gh 3907
562560
df = DataFrame([["foo", "bar", "bah"], ["bar", "foo", "bah"]])
@@ -960,7 +958,6 @@ def test_replace_limit(self):
960958
# TODO
961959
pass
962960

963-
@pytest.mark.xfail(using_string_dtype(), reason="can't set float into string")
964961
def test_replace_dict_no_regex(self):
965962
answer = Series(
966963
{
@@ -1102,7 +1099,6 @@ def test_replace_swapping_bug(self, using_infer_string):
11021099
expect = DataFrame({"a": ["Y", "N", "Y"]})
11031100
tm.assert_frame_equal(res, expect)
11041101

1105-
@pytest.mark.xfail(using_string_dtype(), reason="can't set float into string")
11061102
def test_replace_period(self):
11071103
d = {
11081104
"fname": {
@@ -1139,7 +1135,6 @@ def test_replace_period(self):
11391135
result = df.replace(d)
11401136
tm.assert_frame_equal(result, expected)
11411137

1142-
@pytest.mark.xfail(using_string_dtype(), reason="can't set float into string")
11431138
def test_replace_datetime(self):
11441139
d = {
11451140
"fname": {
@@ -1641,7 +1636,6 @@ def test_regex_replace_scalar(
16411636
expected.loc[expected["a"] == ".", "a"] = expected_replace_val
16421637
tm.assert_frame_equal(result, expected)
16431638

1644-
@pytest.mark.xfail(using_string_dtype(), reason="can't set float into string")
16451639
@pytest.mark.parametrize("regex", [False, True])
16461640
def test_replace_regex_dtype_frame(self, regex):
16471641
# GH-48644

pandas/tests/series/methods/test_replace.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,10 +403,6 @@ def test_replace_categorical(self, categorical, numeric, using_infer_string):
403403
ser = pd.Series(categorical)
404404
msg = "Downcasting behavior in `replace`"
405405
msg = "with CategoricalDtype is deprecated"
406-
if using_infer_string:
407-
with pytest.raises(TypeError, match="Invalid value"):
408-
ser.replace({"A": 1, "B": 2})
409-
return
410406
with tm.assert_produces_warning(FutureWarning, match=msg):
411407
result = ser.replace({"A": 1, "B": 2})
412408
expected = pd.Series(numeric).astype("category")
@@ -747,8 +743,10 @@ def test_replace_regex_dtype_series(self, regex):
747743
@pytest.mark.parametrize("regex", [False, True])
748744
def test_replace_regex_dtype_series_string(self, regex):
749745
series = pd.Series(["0"], dtype="str")
750-
expected = pd.Series([1], dtype=object)
751-
result = series.replace(to_replace="0", value=1, regex=regex)
746+
expected = pd.Series([1], dtype="int64")
747+
msg = "Downcasting behavior in `replace`"
748+
with tm.assert_produces_warning(FutureWarning, match=msg):
749+
result = series.replace(to_replace="0", value=1, regex=regex)
752750
tm.assert_series_equal(result, expected)
753751

754752
def test_replace_different_int_types(self, any_int_numpy_dtype):

0 commit comments

Comments
 (0)