Description
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
import pandas
series = pandas.Series([1])
series.index = index=pandas.date_range("20180101", periods=1)
inOperatorOutput = 1 in series
listOperatorOutput = 1 in list(series)
assert inOperatorOutput == listOperatorOutput
Problem description
This code yields an assertion error. Because the in
operator looks into the index of a series while the list function will take the values.
This is not the same way how python lists and other python objects work and therefore it confuses people. I think the best solution would be to let the in
operator take the values instead of the index.
FYI, here is an SO thread about this topic: https://stackoverflow.com/questions/51962778/python-in-operator-not-working-as-expected-when-comparing-string-and-strftime-va/51962950?noredirect=1#comment121535570_51962950