@@ -754,7 +754,9 @@ class TestReplaceSeriesCoercion(CoercionBase):
754
754
method = "replace"
755
755
756
756
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 ]
758
760
rep ["int64" ] = [4 , 5 ]
759
761
rep ["float64" ] = [1.1 , 2.2 ]
760
762
rep ["complex128" ] = [1 + 1j , 2 + 2j ]
@@ -834,6 +836,7 @@ def replacer(self, how, from_key, to_key):
834
836
def test_replace_series (self , how , to_key , from_key , replacer ):
835
837
index = pd .Index ([3 , 4 ], name = "xxx" )
836
838
obj = pd .Series (self .rep [from_key ], index = index , name = "yyy" )
839
+ print (obj .dtype , from_key )
837
840
assert obj .dtype == from_key
838
841
839
842
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):
877
880
@pytest .mark .parametrize (
878
881
"from_key" , ["datetime64[ns, UTC]" , "datetime64[ns, US/Eastern]" ], indirect = True
879
882
)
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 ):
883
884
index = pd .Index ([3 , 4 ], name = "xyz" )
884
885
obj = pd .Series (self .rep [from_key ], index = index , name = "yyy" )
885
886
assert obj .dtype == from_key
886
887
887
888
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
892
890
893
891
msg = "Downcasting behavior in `replace`"
894
892
warn = FutureWarning if exp .dtype != object else None
0 commit comments