Closed hayd closed 11 years ago
I don't think df2[['A', 'A1']]
should work with this, right? Because that's selecting for two individual columns 'A'
and 'A1'
. The tuple version ought to. Have you tried bisecting through earlier commits to see where this behavior started occurring?
@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, df2[['A','A1']]
raising is correct, and now df2[[('A','A1')]]
works as well
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.