Right now we can compare a Series with a DataFrame through Series.isin
, but is this expected / wanted behaviour?
I would say this should raise, since expectations can be pretty ambiguous here and is confusing to me.
Also the documentation right now states that the values
parameter should be "set or list-like"
Code example:
values = list("ABCD")
s = pd.Series(values)
df = pd.DataFrame({"Column": values})
print(s)
0 A
1 B
2 C
3 D
dtype: object
print(df)
Column
0 A
1 B
2 C
3 D
# comparing DataFrame to Series, this is okay (right?) and I understand the result
df.isin(s)
Column
0 True
1 True
2 True
3 True
# comparing a series to df, what do we expect here? Should this raise? Why do you want to compare a Series to a DataFrame?
s.isin(df)
0 False
1 False
2 False
3 False
dtype: bool
Proposal: when passing anything else than "set or list-like" should raise in Series.isin
Comment From: mzeitlin11
+1 on this - can't think of a compelling use case and assuming this behavior is not well-defined or tested. Would this require a deprecation first, or could it be treated as a bug?
Comment From: erfannariman
I would say this looks more like a bug to me. So I would be -1 for a deprecation cycle.
Comment From: programmingismyfuture
take