根据其他数据框的列将列添加到数据框

时间:2018-10-29 19:10:11

标签: python pandas dataframe

我有两个数据框:subhalo_field和halo_field

  halo_index
0 3447
1 3447
2 5286
3 3124
4 3124
...

因此halo_index列值不是唯一的。 我的另一个数据框是halo_field:

  index rh
0 3447  2
1 5286  5
2 3124  10
...

halo_field.index值是唯一的,并且出现在subhalo_field.halo_index列中(有时很多次)。我想将列添加到subhalo_field数据框(第一个),所以它看起来像这样:

  halo_index rh
0 3447       2
1 3447       2
2 5286       5
3 3124       10
4 3124       10
...

能帮我吗?

0 个答案:

没有答案
相关问题