-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REGR: undocumented astype("category").astype(str) type inconsistency between pandas 1.1 & 1.2 #42087
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
REGR: undocumented astype("category").astype(str) type inconsistency between pandas 1.1 & 1.2 #42087
Conversation
simonjayhawkins
commented
Jun 17, 2021
- closes BUG: undocumented astype("category").astype(str) type inconsistency between pandas 1.1 & 1.2 #41797
- tests added / passed
- Ensure all linting tests pass, see here for how to run them
- whatsnew entry
…between pandas 1.1 & 1.2
pandas/core/arrays/categorical.py
Outdated
@@ -523,14 +523,17 @@ def astype(self, dtype: Dtype, copy: bool = True) -> ArrayLike: | |||
try: | |||
new_cats = np.asarray(self.categories) | |||
new_cats = new_cats.astype(dtype=dtype, copy=copy) | |||
fill_value = np.array(np.nan).astype(dtype).item() |
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.
there are cases where .item() has weird behavior and we use lib.item_from_zerodim instead. no idea if any of those cases are reachable here
thanks @simonjayhawkins |
This comment has been minimized.
This comment has been minimized.
@meeseeksdev backport 1.2.x |
@meeseeksdev backport 1.3.x |
This comment has been minimized.
This comment has been minimized.
cc @simonjayhawkins attempted backport to 1.2.x & 1.3.x |
…stype(str) type inconsistency between pandas 1.1 & 1.2
1.3.x backport ok, 1.2.x needs manual. will do shortly. |
… type inconsistency between pandas 1.1 & 1.2 (#42157) Co-authored-by: Simon Hawkins <[email protected]>
…stype(str) type inconsistency between pandas 1.1 & 1.2
… type inconsistency between pandas 1.1 & 1.2 (#42165)
…between pandas 1.1 & 1.2 (pandas-dev#42087)
…between pandas 1.1 & 1.2 (pandas-dev#42087)