【发布时间】:2023-01-14 23:45:18
【问题描述】:
我有一张这样的桌子
| emp_id | emp_role | mgr_id | mgr_role |
|---|---|---|---|
| 111 | AP | 112 | SP |
| 112 | SP | 116 | DP |
| 114 | LP | 115 | DP |
对于每个员工,我需要打印 emp_role、他的 mgr_id 和 mgr_role
我试过这个
for id in df['emp_id']:
print(id + 'with role' + df['emp_role'] + 'is reporting to' + df['mgr_id'] + 'with role' + df['mgr_role']
这会多次打印输出,但我只需要打印一次。请帮助解决这个问题。提前致谢。
预期输出:
111 with role AP is reporting to 112 with role SP
112 with role SP is reporting to 116 with role DP
114 with role LP is reporting to 115 with role DP
【问题讨论】: