我有兩個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