【发布时间】:2020-04-27 12:38:15
【问题描述】:
例如,我有一个数据框 (df_1),其中一列包含一些文本数据。第二个数据框 (df_2) 包含一些数字。如何检查文本是否包含第二个数据框中的数字?
df_1
Note
0 The code to this is 1003
1 The code to this is 1004
df_2
Code_Number
0 1006
1 1003
所以我想检查 df_1 中 [Note] 中的条目是否包含 df_2 中 [Code_Number] 中的条目
我已尝试使用以下代码:df_1[df_1['Note'].str.contains(df_2['Code_Number'])],并且我知道我无法使用连接,因为我没有用于连接的密钥。
应用过滤后我正在寻找的最终结果是:
Note
0 The code to this is 1003
【问题讨论】:
标签: python pandas data-analysis