-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Predictable order for columns in assign through sorting #9777
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
Comments
this does seem reasonable ther args are passed as kwargs where ordering is not defined |
Agreed, this seems like a sane change. |
@TomAugspurger want this issue? |
I thought about doing this initially but then backed off when I saw PEP 468: https://www.python.org/dev/peps/pep-0468/ which is for preserving the order of **kwargs. Plus the eventual future where pandas runs on pypy, whose dicts are ordered. It'll be a few days before I can get to it probably. |
its a nice idea to have the ordering for |
FYI https://www.python.org/dev/peps/pep-0468/ was actually accepted for 3.6 at the last minute (thanks to dicts maintaining sort order now). Is this worth revisiting this now? It'd only be for 3.6+, so users writing code would need to be aware of that. Seems like a cause for subtle bugs if you're writing code that should support earlier versions. |
Yes, we should revisit this, though I don't see it being a major pain point so there's no rush. Maybe for pandas 2.0? By the time pandas 2.0 is out we'll probably all be using Python 3.6 day to day anyways. |
The order of columns coming out of
.assign
is hard to predictWould it be reasonable to keep all existing keys in their current location and then add the remaining keys in sorted order at the end?
The text was updated successfully, but these errors were encountered: