API: alignment behaviour of Series as assignment value in indexing #37516
Labels
API - Consistency
Internal Consistency of API/Behavior
Bug
Indexing
Related to indexing on series/frames, not to indexes themselves
Follow up on #37427
Currently, there is an inconsistency between
__getitem__
andloc
related to how the RHS value in an assignment gets re-aligned or not.In this example, the values in Series get just assigned as is, ignoring the index of the series (only requiring that the length matches the number of values in the indexer):
However, with
loc
we have a different behaviour: the Series gets basically aligned withs
first, and then this realigned series is also indexed withidx
, and those values get set:you could write what basically happens more explicitly as:
To have the same behaviour as
__getitem__
, you need to assign with an array instead of series:The text was updated successfully, but these errors were encountered: