-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: NBC change in reindexing logic of Series.__setitem__ in pandas=1.1.0 #37427
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
@kozlov-alexey Thanks a lot for the detailed report! I think this wasn't an intentional change, at least it certainly seems so from the PR (as it was only meant as a code clean-up). It's an unfortunate inconsistency between |
out fo curiosity, what does NBC stand for in this context? |
A non-backward compatible change. I thought it's well-spread but it turns it doesn't) |
moved off 1.1.4 milestone (scheduled for release tomorrow) as no PRs to fix in the pipeline |
I put up a PR reverting part of the cleaning PR that caused this. If it's an acceptable fix, we can still merge by tomorrow morning: #37502 |
I opened a follow-up issue to actually discuss which behaviour we want long term (the non-alignment of |
@jorisvandenbossche Hi, it seems the rollback in #37502 left few lines untouched, literally these: and because of this same issue still appears with non-integer dtype keys. For example:
Although there's ongoing discussion on what behavior is correct, can you maybe fully revert back to previous behavior for the time being? Best Regards, |
any reason not to do |
@jbrockmendel That's possible of course, but it is still a workaround, and currently it will work with integer keys one way (i.e. old behavior of getitem) and with the rest of keys other way (new behavior of loc). Isn't it better to rollback back to old behavior for all cases? |
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Hi,
The following example of using
Series.__setitem__
shows different results on pandas=1.0.5 and pandas=1.1.3:It looks like #33643 changed the semantics of setitem operation when assigned values are
pandas.Series
, i.e. the old-behavior was to first align value with idx and then assign value items to S1 basing on idx.values as index labels, so result was:And now the result is as if
S1[idx]
took precedence before the actual assignment, so that labels inidx.values
which are absent invalue.index
are assigned NaNs:Can you please confirm this was intentional change (as I don't see any tests updated to reflect that, nor there are mentions in "What’s new in 1.1.0" section of the documentation)? From the user perspective it looks like with new implementation, user will have to ensure that
value.index == idx.values
to achieve the same result, which is not a big deal of course, but still it's some additional code.First version where the issue appears:
Kind Regards,
Alexey.
The text was updated successfully, but these errors were encountered: