Closed
Description
I noticed that .loc
and __setitem__
behave very differently when assigning one series to a sub-range of another series:
>>> s = pd.Series(0.0, index=list('abcd'))
>>> s1 = pd.Series(1.0, index=list('ab'))
>>> s2 = pd.Series(2.0, index=list('xy'))
>>> s[['a', 'b']] = s2
>>> s # names of s2 are ignored as expected
a 2.0
b 2.0
c 0.0
d 0.0
dtype: float64
>>> s.loc[['a', 'b']] = s2
>>> s # not expected!!
a NaN
b NaN
c 0.0
d 0.0
dtype: float64
>>> s.loc[['a', 'b']] = s1
>>> s # everything's fine if the indices match
a 1.0
b 1.0
c 0.0
d 0.0
dtype: float64
I'm not sure if this is intended behaviour but it seems odd.
I'm on pandas v. 0.24.1