-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: using .ix with a multi-index indexer #11400
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
Conversation
@@ -11,6 +11,7 @@ | |||
from numpy import nan | |||
from numpy.random import randn | |||
import numpy as np | |||
from numpy.testing import assert_allclose |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't use this
@@ -788,6 +789,50 @@ def test_loc_setitem_multiindex(self): | |||
result = df.loc[(t,n),'X'] | |||
self.assertEqual(result,3) | |||
|
|||
def test_ix_setitem_multiindex(self): | |||
# GH5206 | |||
df = pd.DataFrame(np.random.random((5, 5)), columns='A,B,C,D,E'.split(',')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test for .ix
and .loc
(you can make a check function to simplify)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also going to change this test to not use np.random
I think, as I note my row selection is <0.5
below, and thus the test inputs will be different between runs, which seems like a bad smell.
748aed1
to
abfef83
Compare
Updated with comments from review. I have consolidated the tests |
abfef83
to
e3a73de
Compare
pls add a whatsnew note (bug fixes), looks good otherwise. |
e3a73de
to
c10b890
Compare
Thanks - rebased on master, added whatsnew and pushed. |
@@ -443,11 +443,14 @@ def can_do_equal_len(): | |||
# we have an equal len Frame | |||
if isinstance(value, ABCDataFrame) and value.ndim > 1: | |||
sub_indexer = list(indexer) | |||
indexer_multiindex = isinstance(labels, MultiIndex) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about rename this to multiiindex_indexer
(for a bit of consistency)
Add an optional argument to _NDFrameIndexer._align_series to indicate if the indexer is from a MultiIndex
c10b890
to
3d84a72
Compare
Renamed to |
@rekcahpassyla thanks! that was a nice deep dive. lots of other indexing issues if you'd like 😄 |
Welcome! In the short term, a bit pressed for time but we are testing our entire library against |
closes #11372
Add an optional argument to _NDFrameIndexer to indicate
if the indexer is from a MultiIndex