i have 2 data frames which are group and cite
assume that this is my df_group
label groupId
1 123
2 124
3 125
4 126
5 127
and df_cite
groupId new_group
123 96
124 96
125 96
123 97
124 99
124 98
125 98
126 97
127 99
i would like to see the new df_group results as
df_group (new)
label groudId new_group
1 123 96
2 123 97
3 124 96
4 124 98
5 124 99
6 125 96
7 125 98
8 126 97
9 127 99
i have tried test_out = df_group.merge(df_cite, left_on='groupId', right_on='groupId')
and df_group = df_group.join(df_cite.set_index('groupId'), on=['PatNumgroupId'])
but both are not working.
further to this Python: how to merge two dataframes on a column by keeping the information of the first one?, i have followed but got the InvalidIndexError: Reindexing only valid with uniquely valued Index objects
instead