我正在尝试用不同的值填充 df 。
第一个df是:
第二个df是:
我想将该列添加到第一个 df 具有来自第二个的值以接收输出:
| 数字 | 反式 | 日期 | 价值 |
|---|---|---|---|
| HF01 | 一 | 麦粒肿 | 1 |
| HF01 | 一 | 卢特 | 2 |
| - | - | - | - |
| HF05 | 五 | 帕兹 | 50 |
我想出了代码:
found = []
for index, row in one.iterrows():
for ind, rw in two.iterrows():
if ind not in found:
if (one.loc[index, 'number'] == two.loc[ind, 'number']) & \
(one.loc[index, 'trans'] == two.loc[ind, 'trans']) & \
one.loc[index,'value'] = two.loc[ind, one.loc[index, 'date']]
found.append(int(ind))
break
它可以工作,但速度非常慢。应该如何正确完成?

