I have 2 dataframes, one (df1) with latitudes and longitudes of a specific place, and one (df2) with latitude of longitude of a city with the city name. I want to (left) join the city name from df2 as a new column in df1 based on the nearest latitude/longitude.
In other words, I want to compare the latitude and longitude of df1 with those of df2 and then join the corresponding city from df2 on df1.
df1
amount | latitude | longitude |
---|---|---|
1 | 20 | 2 |
4 | 18 | 8 |
3 | 20 | 10 |
6 | 5 | 1 |
df2
City | latitude | longitude |
---|---|---|
A | 16 | 8 |
B | 12 | 12 |
C | 20 | 15 |
D | 4 | 28 |