Dataframe in question, df:
colA colB
1 [1, 4, 5]
4 [3, nan, nan]
I'm trying to return a Series which has True where colA's value is in colB's value for each row.
The result should be:
True
False
I tried: df.colA.isin(df.colB)
- but that doesn't do the trick because colB's values are in lists
您需要在isin
之前解压列表列
m = pd.DataFrame(df['colB'].tolist(),index=df.index).isin(df['colA']).any(axis=1)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.