Skip to content

Commit e8390b9

Browse files
committed
adjust replace tests for infer_string
1 parent 01b5d26 commit e8390b9

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

pandas/tests/indexing/test_coercion.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,9 @@ class TestReplaceSeriesCoercion(CoercionBase):
754754
method = "replace"
755755

756756
rep: dict[str, list] = {}
757-
rep["object"] = ["a", "b"]
757+
rep["object"] = [1, "b"]
758+
rep["str"] = ["a", "b"]
759+
rep["string"] = ["a", "b", None]
758760
rep["int64"] = [4, 5]
759761
rep["float64"] = [1.1, 2.2]
760762
rep["complex128"] = [1 + 1j, 2 + 2j]
@@ -834,6 +836,7 @@ def replacer(self, how, from_key, to_key):
834836
def test_replace_series(self, how, to_key, from_key, replacer):
835837
index = pd.Index([3, 4], name="xxx")
836838
obj = pd.Series(self.rep[from_key], index=index, name="yyy")
839+
print(obj.dtype, from_key)
837840
assert obj.dtype == from_key
838841

839842
if from_key.startswith("datetime") and to_key.startswith("datetime"):
@@ -877,18 +880,13 @@ def test_replace_series(self, how, to_key, from_key, replacer):
877880
@pytest.mark.parametrize(
878881
"from_key", ["datetime64[ns, UTC]", "datetime64[ns, US/Eastern]"], indirect=True
879882
)
880-
def test_replace_series_datetime_tz(
881-
self, how, to_key, from_key, replacer, using_infer_string
882-
):
883+
def test_replace_series_datetime_tz(self, how, to_key, from_key, replacer):
883884
index = pd.Index([3, 4], name="xyz")
884885
obj = pd.Series(self.rep[from_key], index=index, name="yyy")
885886
assert obj.dtype == from_key
886887

887888
exp = pd.Series(self.rep[to_key], index=index, name="yyy")
888-
if using_infer_string and to_key == "object":
889-
assert exp.dtype == "string"
890-
else:
891-
assert exp.dtype == to_key
889+
assert exp.dtype == to_key
892890

893891
msg = "Downcasting behavior in `replace`"
894892
warn = FutureWarning if exp.dtype != object else None

0 commit comments

Comments
 (0)