-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DataFrame MultiIndex column access (and pop) #4145
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
I don't think |
@jreback No that shouldn't work (just was surprised it was doing something different to the tuple - as I thought it meant the tuple was being captured somehow, presumably as part of a MultiIndex...). I haven't tried bisecting (ever) will have a go now. |
@hayd Tuple is treated differently than list - tuples are considered a single element for the purposes of indexing, whereas a list is the (only?) way to have your input treated as a list of elements/lookups. So if you want to index into a MultiIndex, you ultimately have to use a tuple to get to it. |
this is all pretty simple, PR coming shortly...basically an oversight |
@jreback wow...that's pretty amazing that you can tell what's wrong so quickly. |
nah...it was obvious once the test case hit it that the code was returning an incomplete answer (just the resulting values and not a full block manager); I had written the code so knew where it was (but I guess never explictiy made a test to validate that case)....its kind of deep...have to have a non-unique column index, and selecting a unique value from it (the original case was to handle selecting the non-unique values) |
see pr #4148, |
Suppose I want to acces a column in df2 (perhaps there is a near way, but I also expect these to work):
I want to access the column
('A', 'A1')
:I had assumed/hoped this would work:
Also this way is buggy (loses the index)... which is weird, separated this part of the issue as #4146:
pop uses this in it's implementation, so atm it's not possible to pop a MultiIndex.
The text was updated successfully, but these errors were encountered: