Skip to content

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

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

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

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

manuteleco opened this issue Aug 9, 2012 · 1 comment
Labels
Milestone

Comments

@manuteleco
Copy link

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 as completed in ded51c8 Aug 13, 2012
@wesm
Copy link
Member

wesm 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
Labels
Projects
None yet
Development

No branches or pull requests

2 participants