Do you want to use isin :
In [121]: s2[s2.isin(s1)] Out[121]: 000007720 group1 -3732.05 group2 -38147.87 FSHLAJ -36711.09 Name: 2000.00, dtype: float64
I donβt know in which direction you wanted to perform the comparison, thatβs all:
In [122]: s1[s1.isin(s2)] Out[122]: 000007720 group1 -3732.05 group2 -38147.87 FSHLAJ -36711.09 Name: 2000.00, dtype: float64
The problem with trying to make s1 == s2 is that it makes no sense to compare rows or arrays of different lengths.
If you want the indices to match, add this as a condition:
In [131]: s1[(s1.index.isin(s2.index)) & (s1.isin(s2))] Out[131]: 000007720 group1 -3732.05 group2 -38147.87 FSHLAJ -36711.09 Name: 2000.00, dtype: float64
Edchum
source share