@@ -1689,9 +1689,8 @@ def _convert_to_ndarrays(
16891689 values , set (col_na_values ) | col_na_fvalues , try_num_bool = False
16901690 )
16911691 else :
1692- is_str_or_ea_dtype = is_string_dtype (
1693- cast_type
1694- ) or is_extension_array_dtype (cast_type )
1692+ is_ea = is_extension_array_dtype (cast_type )
1693+ is_str_or_ea_dtype = is_ea or is_string_dtype (cast_type )
16951694 # skip inference if specified dtype is object
16961695 # or casting to an EA
16971696 try_num_bool = not (cast_type and is_str_or_ea_dtype )
@@ -1706,16 +1705,15 @@ def _convert_to_ndarrays(
17061705 not is_dtype_equal (cvals , cast_type )
17071706 or is_extension_array_dtype (cast_type )
17081707 ):
1709- try :
1710- if (
1711- is_bool_dtype (cast_type )
1712- and not is_categorical_dtype (cast_type )
1713- and na_count > 0
1714- ):
1715- raise ValueError (f"Bool column has NA values in column { c } " )
1716- except (AttributeError , TypeError ):
1717- # invalid input to is_bool_dtype
1718- pass
1708+ if not is_ea and na_count > 0 :
1709+ try :
1710+ if is_bool_dtype (cast_type ):
1711+ raise ValueError (
1712+ f"Bool column has NA values in column { c } "
1713+ )
1714+ except (AttributeError , TypeError ):
1715+ # invalid input to is_bool_dtype
1716+ pass
17191717 cvals = self ._cast_types (cvals , cast_type , c )
17201718
17211719 result [c ] = cvals
0 commit comments