This article describes how the pandas series with the index index is vectorized:
1. Index indexed arrays are the same:
S1 = PD. Series ([1, 2, 3, 4], index=['a','b','C','D']) S2= PD. Series ([ten, +, +], index=['a','b','C','D'])PrintS1 +s2a11b22C33D44Dtype:int64
Add the values corresponding to each index directly
2. Index indexed array values are the same, in different order:
S1 = PD. Series ([1, 2, 3, 4], index=['a','b','C','D']) S2= PD. Series ([ten, +, +], index=['b','D','a','C'])PrintS1 +s2a31b12C43D24Dtype:int64
Add the values corresponding to each index, whichever is the first series
3. Index indexed array Some values are the same, some values are different:
S1 = PD. Series ([1, 2, 3, 4], index=['a','b','C','D']) S2= PD. Series ([ten, +, +], index=['C','D','e','F'])PrintS1 +s2a nanb NaNc13.0D24.0e nanf NaN
The values corresponding to the same index values are added differently because they are not found, so the Nan is returned
4. Index indexed arrays are completely different:
S1 = PD. Series ([1, 2, 3, 4], index=['a','b','C','D']) S2= PD. Series ([ten, +, +], index=['e','F','g','h'])PrintS1 +s2a nanb NaNc NaNd NaNe nanf NaNg Nanh Nandtype:float64
Because there is no same index, the series cannot be added, and the result is Nan
Pandas Array (Pandas Series)-(3) Vectorization operations