I have two dataframes. First:
country city
0 Norway a
1 Norway a
2 Norway a
3 Norway b
4 Norway b
5 Norway b
6 Sweden c
7 Sweden c
8 Sweden c
9 Sweden c
10 Sweden d
11 Sweden d
12 Sweden d
and second:
city region
0 a 1
1 a 2
2 b 3
3 b 4
4 c 5
5 c 6
6 c 7
7 d 8
How can I get the following dataframe? We just need to assign a correct country to the corresponding city as a new column in the second dataframe.
country city region
0 Norway a 1
1 Norway a 2
2 Norway b 3
3 Norway b 4
4 Sweden c 5
5 Sweden c 6
6 Sweden c 7
7 Sweden d 8
I have tried to use merge and mapping, but could not succeed.