You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing this SO answer, I came upon this behavior, which I did not expect.
In [1]: 1 in Series([1])
Out[1]: False
In [2]: 1 in Series([1, 2])
Out[2]: True
Apparently, __contains__ looks at the index.
In [3]: 1 in Series([1], index=[1])
Out[3]: True
I can see how that makes sense. But I think it's fair to say that it is potentially confusing. Do we rely on this behavior of __contains__ for data alignment? Might it be reasonable to change it? I'm not sure that's a good idea, but I want to raise the issue.
The text was updated successfully, but these errors were encountered:
IIRC this is for dict compat, IOW a series is dict like with the index being the keys and the values the actual values. So its consistent. For a frame, the __contains__ works on the columns axis.
When writing this SO answer, I came upon this behavior, which I did not expect.
Apparently,
__contains__
looks at the index.I can see how that makes sense. But I think it's fair to say that it is potentially confusing. Do we rely on this behavior of
__contains__
for data alignment? Might it be reasonable to change it? I'm not sure that's a good idea, but I want to raise the issue.The text was updated successfully, but these errors were encountered: