When using the ==
operator I am asking python whether two objects are equal. Therefore when I execute the following code I get the expected result:
In[1]: 'apple' == ['banana', 'apple']
Out[1]: False
However when using a Pandas Series object I don't get the same result. It appears that instead of evaluating the two objects as they are, the ==
operator iterates over the Series. See the following example:
In[2]: 'apple' == pd.Series(['banana', 'apple'])
Out[2]: 0 False
1 True
My question is why does this occur? Whilst I find it useful it seems counter intuitive.
question from:
https://stackoverflow.com/questions/65542129/pandas-series-and-the-operator 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…