-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Assignment of subpart of data frame with multi index yields user surprise #18120
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
Comments
@kghosesbg : Thanks for reporting this! Looks quite odd to me indeed. This is reproducible on |
This is expected, you are assigning mismatched levels. It is pretty tricky to actually figure out what you are doing is invalid. Sure you can make an assumption that you are assigning based on sub-levels, or that the levels don't match on the left and right sides, but this is pretty fragile.
This is the correct method, essentially no alignment and a direct assignment.
This is very simliar in concept to the warning at the end of this section. http://pandas.pydata.org/pandas-docs/stable/indexing.html#basics |
@kghosesbg we need someone to collect the cases for MultiIndex and write/re-write the logic a bit. I am not opposed to raising in a case like this, but this requires some investigation. Would be great just to have the cases listed (and we can xfail them). Then tackle later. would you be interested in this? |
Hi @jreback I'm happy to help as needed, though it might go slowly. Could you please clarify the task. From you previous comment I understand that you'd like to add this example to the multi-indexing docs, which I can do. Is the next to collect reports of these cases and put them in the test suite? |
yep those are the tasks |
This was unexpected. I realize that the indexes do not match, and hence this behavior, but I expect Pandas to throw an Exception, rather than silently do this
This was, of course, the behavior I was expecting
The text was updated successfully, but these errors were encountered: