-
-
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
Conversation
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.
Thanks!
I only added a note about is_bool_dtype in the whatsnew as the DataFrame.setitem issue does not occur on 1.1.x. It didn't seem appropriate for any section besides other.
Indeed, if it's only a regression in master / 1.2rc, no need for a whatsnew
# property would require instantiation | ||
if not isinstance(dtype.name, property) | ||
], | ||
*["datetime64[ns, UTC]", "period[D]"], |
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.
Sorry, but I find this ridiculous. And not you, but mypy ;) (since when are lists supposed to be of homogeneous content?)
If mypy can't deal with it, I would just add a ignore comment, instead of the unpacking into a list
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.
+1
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.
Done.
doc/source/whatsnew/v1.2.0.rst
Outdated
@@ -856,7 +856,7 @@ Other | |||
- Bug in :meth:`Index.drop` raising ``InvalidIndexError`` when index has duplicates (:issue:`38051`) | |||
- Bug in :meth:`RangeIndex.difference` returning :class:`Int64Index` in some cases where it should return :class:`RangeIndex` (:issue:`38028`) | |||
- Fixed bug in :func:`assert_series_equal` when comparing a datetime-like array with an equivalent non extension dtype array (:issue:`37609`) | |||
|
|||
- Bug in :func:`.is_bool_dtype` would raise when passed a valid string such as ``"boolean"`` (:issue:`38386`). |
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.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
comment that this is de facto an isinstance(dtype, BooleanDtype)
?
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.
I think this might also return True for certain sparse and categorical.
pandas/io/parsers.py
Outdated
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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Done
thanks @rhshadrach |
@meeseeksdev backport 1.2.x |
…ises (#38464) Co-authored-by: Richard Shadrach <[email protected]>
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Previous behavior in
io.parsers
depended onis_bool_dtype("boolean")
erroneously raisingAttributeError
.Test currently iterates over the names:
It skips any EA where the name is a property; I don't see a good way to iterate over these in the test.
I only added a note about
is_bool_dtype
in the whatsnew as theDataFrame.__setitem__
issue does not occur on 1.1.x. It didn't seem appropriate for any section besides other.