-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REGR: Assigning label with registered EA dtype raises #38427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
0498023
74b2df9
ed81c90
a3cbfec
605d3f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1397,7 +1397,7 @@ def is_bool_dtype(arr_or_dtype) -> bool: | |
# guess this | ||
return arr_or_dtype.is_object and arr_or_dtype.inferred_type == "boolean" | ||
elif is_extension_array_dtype(arr_or_dtype): | ||
return getattr(arr_or_dtype, "dtype", arr_or_dtype)._is_boolean | ||
return getattr(dtype, "_is_boolean", False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment that this is de facto an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this might also return True for certain sparse and categorical. |
||
|
||
return issubclass(dtype.type, np.bool_) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1689,9 +1689,8 @@ def _convert_to_ndarrays( | |
values, set(col_na_values) | col_na_fvalues, try_num_bool=False | ||
) | ||
else: | ||
is_str_or_ea_dtype = is_string_dtype( | ||
cast_type | ||
) or is_extension_array_dtype(cast_type) | ||
is_ea = is_extension_array_dtype(cast_type) | ||
is_str_or_ea_dtype = is_string_dtype(cast_type) or is_ea | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. put is_ea first to short-circuit the other check There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
# skip inference if specified dtype is object | ||
# or casting to an EA | ||
try_num_bool = not (cast_type and is_str_or_ea_dtype) | ||
|
@@ -1707,11 +1706,7 @@ def _convert_to_ndarrays( | |
or is_extension_array_dtype(cast_type) | ||
): | ||
try: | ||
if ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can the if go outside the try instead of the other way around? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
is_bool_dtype(cast_type) | ||
and not is_categorical_dtype(cast_type) | ||
and na_count > 0 | ||
): | ||
if not is_ea and na_count > 0 and is_bool_dtype(cast_type): | ||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
|
||
raise ValueError(f"Bool column has NA values in column {c}") | ||
except (AttributeError, TypeError): | ||
# invalid input to is_bool_dtype | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo extra period before is_bool_dtype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The period before
is_bool_dtype
allows sphinx link to the proper page; without it, a link will not be made. However, the period after the issue number is a typo.