[英]Joining two dataframes in Pandas remove value from another dataframe
If I understood you right:如果我理解正确:
tran[~tran.UserID.isin(users.UserID)]
will give you tran df with only the user ids that are not user df将为您提供 tran df 仅包含非用户 df 的用户 ID
Easily you can use sqldf
:您可以轻松地使用sqldf
:
from pandasql import sqldf
pysqldf = lambda q: sqldf(q, globals())
pysqldf("SELECT tran.*
FROM tran
WHERE tran.UserId NOT IN (SELECT UserId FROM users)") \
.head()
You could try this -你可以试试这个——
tran_filt = tran[~(tran['UserId'].isin(users['UserId'].tolist()))]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.