如果我需要查看2列中2个工作簿之间的值是否相同,以及是否从第一个工作簿中删除了该行。有没有比在for循环中运行它更快的方法?我听说过矢量化比较,但不知道它在这种情况下是否合适:
DF1:
FXMLLoader loader = new FXMLLoader(getClass().getResource("RenewCardFXML2.fxml"));
detailsPane = loader.load();
DF2:
Match ID1 ID2 ID1_source ID2_source
x.1 1 2 a b
x.2 2 3 b c
x.3 4 5 c a
x.4 1 3 b c
x.5 5 6 a b
在此示例中,必须删除包含x.1和x.3的行。值得注意的是,每个Match都是唯一的,具有唯一的ID1和ID2。
代码:
Match ID1 ID2 ID1_source ID2_source Notes ...
x.768 8 0 a c ///
x.647 9 4 b a ///
x.1 1 2 a b ///
...
x.3 4 5 c a ///
答案 0 :(得分:0)
您可以将遮罩与数据框一起使用。所以
not_equal = (df1['ID1','ID2'] != df2['ID1','ID2']).all()
df1= df1[not_equal, :]