-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: fix construction of Series / Index from dict keys when "str" dtype is specified explicitly #60436
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
@jorisvandenbossche Can you check now please and if possible merge? I considered your comments in this updated PR and added the generic if. Now besides the dict.keys(), it will handle other iterable such as dict.values() and addressing other similar types. My IDE is throwing some unintentional formatting issues which I can't seem to undo, but in this commit, I only changed the if condition in the construction.py and nothing else |
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. |
Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen. |
e719b61
to
92781f5
Compare
@tasfia8 thanks for the initial contribution! |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
…pe is specified explicitly (pandas-dev#60436) Co-authored-by: Joris Van den Bossche <[email protected]> (cherry picked from commit 84bf1ef)
Manual backport -> #60793 |
…ys when "str" dtype is specified explicitly (#60436) (#60793) BUG: fix construction of Series / Index from dict keys when "str" dtype is specified explicitly (#60436) Co-authored-by: Joris Van den Bossche <[email protected]> (cherry picked from commit 84bf1ef) Co-authored-by: tasfia8 <[email protected]>
The default behavior (pd.Index(d.keys())) worked correctly, but explicitly setting dtype="str" raised a ValueError. The issue stemmed from dict_keys not being converted to a proper array-like structure before being passed to StringDtype, which couldn't handle such inputs.
To fix the issue:
-Handles Existing Test Cases and fixes previous PR fix issues.
After the fix both the default (pd.Index(d.keys())) and explicit (pd.Index(d.keys(), dtype="str")) cases work: