Skip to content

Assignment broken for sliced multi-indices #16379

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
mwiebusch78 opened this issue May 17, 2017 · 1 comment
Closed

Assignment broken for sliced multi-indices #16379

mwiebusch78 opened this issue May 17, 2017 · 1 comment
Labels
Duplicate Report Duplicate issue or pull request Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex

Comments

@mwiebusch78
Copy link

Consider the following data frame:

>>> df = pd.DataFrame(1.0, index=pd.MultiIndex.from_product([[0, 1], [0, 1]]), columns=['a'])
>>> df
       a
0 0  1.0
  1  1.0
1 0  1.0
  1  1.0

Taking a slice of this and assigning it to itself should leave the data unchanged, but look what happens:

>>> df.loc[(0,), :] = df.loc[(0,), :]
>>> df
       a
0 0  NaN
  1  NaN
1 0  1.0
  1  1.0

I'm on pandas version 0.20.1

@jreback
Copy link
Contributor

jreback commented May 17, 2017

a duplicate of #10440

see the examples there on how to do this. pandas doesn't know how to align your slice. it seems obvious, but is actually non-trivial.

@jreback jreback closed this as completed May 17, 2017
@jreback jreback added Duplicate Report Duplicate issue or pull request Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex labels May 17, 2017
@jreback jreback added this to the No action milestone May 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate Report Duplicate issue or pull request Indexing Related to indexing on series/frames, not to indexes themselves MultiIndex
Projects
None yet
Development

No branches or pull requests

2 participants