-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Undesired auto sort when adding two multiindexes #8864
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
Can you clean up your example to make it copy-pasteable into a REPL so that it's clearer what the problem is? |
Hi, Here's an example code:
You'll see how the 3rd level got sorted automatically. Is there a way I can prevent this? |
@Aurthes you almost ALWAYS want the multi-index to sort to do any type of indexing. What is your usecase? (you can always do |
@Aurthes In the current version of pandas, the If you simply want to concatenate two multi-indexes, you can do this with numpy:
To get the unique (non-sorted) elements (which I think is what you want here), you can then use
This is slightly awkward, but pandas provides all the tools to do it efficiently, and I do believe this sort of use is pretty niche -- we have lots of shortcuts that make this easier when working with dataframes or series. |
Problem solved, very efficient. Thanks! Pandas is great :) |
Thx all ! |
idx0 =
timestamp sequence attribute
2014-11-12 17:02:23.635000-06:00 0 price
count
quantity
idx1 =
timestamp sequence attribute
2014-11-12 17:02:24.060000-06:00 1 price
count
quantity
idx0 + idx1 =
timestamp sequence attribute
2014-11-12 23:02:23.635000 0 count
price
quantity
2014-11-12 23:02:24.060000 1 count
price
quantity
Any way to solve this?
The text was updated successfully, but these errors were encountered: