我有两个dataframes:基于另一个大熊猫据帧有条件地提取大熊猫行
df1:
col1 col2
1 2
1 3
2 4
df2:
col1
2
3
我想提取df1
其中df1
的所有行col2
not in
df2
's col1
。所以在这种情况下,这将是:
col1 col2
2 4
我第一次尝试:
df1[df1['col2'] not in df2['col1']]
但它返回:
TypeError: 'Series' objects are mutable, thus they cannot be hashed
然后我想:
df1[df1['col2'] not in df2['col1'].tolist]
但返回:
TypeError: argument of type 'instancemethod' is not iterable