@@ -552,7 +552,12 @@ def _maybe_downcast(
552
552
return blocks
553
553
554
554
nbs = extend_blocks (
555
- [blk .convert (using_cow = using_cow , copy = not using_cow ) for blk in blocks ]
555
+ [
556
+ blk .convert (
557
+ using_cow = using_cow , copy = not using_cow , convert_string = False
558
+ )
559
+ for blk in blocks
560
+ ]
556
561
)
557
562
if caller == "fillna" :
558
563
if len (nbs ) != len (blocks ) or not all (
@@ -625,6 +630,7 @@ def convert(
625
630
* ,
626
631
copy : bool = True ,
627
632
using_cow : bool = False ,
633
+ convert_string : bool = True ,
628
634
) -> list [Block ]:
629
635
"""
630
636
Attempt to coerce any object types to better types. Return a copy
@@ -655,6 +661,7 @@ def convert(
655
661
res_values = lib .maybe_convert_objects (
656
662
values , # type: ignore[arg-type]
657
663
convert_non_numeric = True ,
664
+ convert_string = convert_string ,
658
665
)
659
666
refs = None
660
667
if (
@@ -904,7 +911,9 @@ def replace(
904
911
if get_option ("future.no_silent_downcasting" ) is True :
905
912
blocks = [blk ]
906
913
else :
907
- blocks = blk .convert (copy = False , using_cow = using_cow )
914
+ blocks = blk .convert (
915
+ copy = False , using_cow = using_cow , convert_string = False
916
+ )
908
917
if len (blocks ) > 1 or blocks [0 ].dtype != blk .dtype :
909
918
warnings .warn (
910
919
# GH#54710
@@ -1007,7 +1016,7 @@ def _replace_regex(
1007
1016
)
1008
1017
already_warned .warned_already = True
1009
1018
1010
- nbs = block .convert (copy = False , using_cow = using_cow )
1019
+ nbs = block .convert (copy = False , using_cow = using_cow , convert_string = False )
1011
1020
opt = get_option ("future.no_silent_downcasting" )
1012
1021
if (len (nbs ) > 1 or nbs [0 ].dtype != block .dtype ) and not opt :
1013
1022
warnings .warn (
@@ -1150,7 +1159,9 @@ def replace_list(
1150
1159
nbs = []
1151
1160
for res_blk in result :
1152
1161
converted = res_blk .convert (
1153
- copy = True and not using_cow , using_cow = using_cow
1162
+ copy = True and not using_cow ,
1163
+ using_cow = using_cow ,
1164
+ convert_string = False ,
1154
1165
)
1155
1166
if len (converted ) > 1 or converted [0 ].dtype != res_blk .dtype :
1156
1167
warnings .warn (
0 commit comments