如何从包含另一个数据框中另一个值中的值的数据框中删除行

时间:2019-07-02 16:21:26

标签: python python-3.x pandas

我有两个数据框。一个比另一个长得多。我只需要其中一个具有值的行,而另一行则位于这些值之内。

本质上,如果我有数据帧1和2,则需要将其中不包含2的值的所有行都删除。例如:如果1中的行的值为'40',而2中的行为'r400-3',则我不希望该行被删除,而所有其他行都需要删除。

我尝试查询,只是比较两者,甚至是for循环。但是我最终都对所有这些错误都有了看法。

df1.query('@df2.a in a', inplace = True) Unalignable boolean Series provided as indexer (index of the boolean Series and of the indexed object do not match

dfb = dfb[dfb.loc[20][dropper_criteria] in dfb.loc[index][dropper_criteria]] KeyError: False

0 个答案:

没有答案