Skip to content
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

Assignment to DataFrame through .ix with non-unique MultiIndex #1750

Closed
manuteleco opened this issue Aug 9, 2012 · 1 comment

Comments

@manuteleco
Copy link

commented Aug 9, 2012

Hi,

I think there might be a bug in the assignment to a DataFrame object through .ix when non-unique MultiIndexes are involved. The next sample code describes this issue:

In [1]: from pandas import DataFrame, MultiIndex

In [2]: 

In [2]: df = DataFrame([[1, 1, "x", "X"], [1, 1, "y", "Y"], [1, 2, "z", "Z"]],
   ...:                columns=list("ABCD"))

In [3]: df = df.set_index(list("AB"))

In [4]: df
Out[4]: 
     C  D
A B      
1 1  x  X
  1  y  Y
  2  z  Z

In [5]: 

In [5]: ix = MultiIndex.from_tuples([(1, 1)])

In [6]: df.ix[ix, "C"]  # Shows both values with index (1, 1)
Out[6]: 
A  B
1  1    x
   1    y
Name: C

In [7]: 

In [7]: df.ix[ix, "C"] = "_"  # Only sets one of the two values with index (1, 1): BUG?

In [8]: df
Out[8]: 
     C  D
A B      
1 1  x  X
  1  _  Y
  2  z  Z


Thanks and regards.
Manu.

@wesm wesm closed this in ded51c8 Aug 13, 2012

@wesm

This comment has been minimized.

Copy link
Member

commented Aug 13, 2012

thanks for the report. fixed this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.