我有两个 Dataframe :DF1:
id type
"a" "alpha"
"a" "alpha"
"a" "beta"
"a" "gamma"
和DF2:
id type
"a" "alpha"
"a" "alpha"
"a" "alpha"
"a" "alpha"
"a" "beta"
"a" "beta"
对于DF1中的每一行,如果它们具有相同的“id”和“type”,则我想要从DF2中移除单个行。
id type
"a" "alpha"
"a" "alpha"
"a" "beta"
我怎么能这么做?
1条答案
按热度按时间nwnhqdif1#
您可以使用
collection.Counter
从df2中减去df1的元素,然后重建 Dataframe :输出:
编辑:为了模块化稍微重构代码