Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
69 views
in Technique[技术] by (71.8m points)

python - Pandas Series and the == operator

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...