File tree 1 file changed +14
-7
lines changed
1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 30
30
astype_array_safe ,
31
31
find_common_type ,
32
32
infer_dtype_from_scalar ,
33
+ soft_convert_objects ,
33
34
)
34
35
from pandas .core .dtypes .common import (
35
36
is_bool_dtype ,
@@ -527,13 +528,19 @@ def convert(
527
528
numeric : bool = True ,
528
529
timedelta : bool = True ,
529
530
) -> ArrayManager :
530
- return self .apply_with_block (
531
- "convert" ,
532
- copy = copy ,
533
- datetime = datetime ,
534
- numeric = numeric ,
535
- timedelta = timedelta ,
536
- )
531
+ def _convert (arr ):
532
+ if is_object_dtype (arr .dtype ):
533
+ return soft_convert_objects (
534
+ arr ,
535
+ datetime = datetime ,
536
+ numeric = numeric ,
537
+ timedelta = timedelta ,
538
+ copy = copy ,
539
+ )
540
+ else :
541
+ return arr .copy () if copy else arr
542
+
543
+ return self .apply (_convert )
537
544
538
545
def replace (self , value , ** kwargs ) -> ArrayManager :
539
546
assert np .ndim (value ) == 0 , value
You can’t perform that action at this time.
0 commit comments