-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: stack doesn't preserve lower precision floating dtypes #51602
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
if common_type.kind == "f" and not is_extension_array_dtype(common_type): | ||
fill_value = common_type.type(np.nan) | ||
else: | ||
fill_value = np.nan |
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.
Any reason for not using common_dtype.na_value?
Right now "Float32" would add np.nan, but this should be pd.NA, Same for Int64 for example
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 default fill_value is np.nan for reindex, even for EAs. That's probably something to fix elsewhere, though (IIRC, the fill value gets converted somewhere in the EA methods, maybe take? It's been a while since I looked into it though).
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.
But why can't we supply the correct one?
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.
Updated.
fill_value = np.nan | ||
value_slice = chunk.reindex( | ||
columns=level_vals_used, fill_value=fill_value | ||
).values |
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.
This is something we'll have to figure out at some point, right now this coerces EA dtypes to object. But ok for another pr since we had this problem before as well...
This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this. |
This looked okay. Could you merge in main once more and add a whatsnew? |
Going to mothball for now but feel free to reopen |
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.