70
70
from pandas .core .dtypes .inference import is_list_like
71
71
from pandas .core .dtypes .missing import isna , notna
72
72
73
- import pandas as pd
74
-
75
73
_int8_max = np .iinfo (np .int8 ).max
76
74
_int16_max = np .iinfo (np .int16 ).max
77
75
_int32_max = np .iinfo (np .int32 ).max
@@ -1051,7 +1049,8 @@ def convert_dtypes(
1051
1049
dtype
1052
1050
new dtype
1053
1051
"""
1054
- if convert_string or convert_integer or convert_boolean :
1052
+ is_extension = is_extension_array_dtype (input_array .dtype )
1053
+ if (convert_string or convert_integer or convert_boolean ) and not is_extension :
1055
1054
try :
1056
1055
inferred_dtype = lib .infer_dtype (input_array )
1057
1056
except ValueError :
@@ -1064,9 +1063,7 @@ def convert_dtypes(
1064
1063
if convert_integer :
1065
1064
target_int_dtype = "Int64"
1066
1065
1067
- if is_integer_dtype (input_array .dtype ) and not is_extension_array_dtype (
1068
- input_array .dtype
1069
- ):
1066
+ if is_integer_dtype (input_array .dtype ):
1070
1067
from pandas .core .arrays .integer import _dtypes
1071
1068
1072
1069
inferred_dtype = _dtypes .get (input_array .dtype .name , target_int_dtype )
@@ -1080,10 +1077,7 @@ def convert_dtypes(
1080
1077
inferred_dtype = input_array .dtype
1081
1078
1082
1079
if convert_boolean :
1083
- if is_bool_dtype (input_array .dtype ) and (
1084
- (not is_extension_array_dtype (input_array .dtype ))
1085
- or (input_array .dtype == pd .BooleanDtype ())
1086
- ):
1080
+ if is_bool_dtype (input_array .dtype ):
1087
1081
inferred_dtype = "boolean"
1088
1082
else :
1089
1083
if isinstance (inferred_dtype , str ) and inferred_dtype == "boolean" :
0 commit comments