-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Support for empty slice in multi indices #8737
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
Ping @SSunkara . |
hmm this should work |
Here it is: import pandas as pd
import numpy as np
multi_index = pd.MultiIndex.from_product((['foo', 'bar', 'baz'], ['alpha', 'beta']))
df = pd.DataFrame(np.random.randn(5, 6), index=range(5), columns=multi_index)
df = df.sortlevel(0, axis=1)
df.loc[:, ([], slice(None))] The version is Here is the error:
Printout of show_versions:
|
I see it..ok will see if can get in for 0.15.1 (releasing this weekend). thanks for the report. |
so this should return an empty frame (with the same index, and column index metadata preserved) e.g.
yes? |
This is what I was expecting from the documentation, but wasn't sure if I was doing something wrong. Hopefully next time, we will open a PR with a correction! |
done (was pretty trivial), sadly don't always catch all of the cases. Note that you should for sure upgrade to 0.14.1 as lots of changes in mi slicing. (of course 0.15.1 even better) :) |
closed by #8739 |
It is currently possible to pass a list of labels for a given dataframe to
DataFrame.loc
in the case of a multi index, but the list cannot be empty unlike in the case of a non-hierarchical index.The text was updated successfully, but these errors were encountered: