I have the following data frame in a Jupyter Notebook that has a list of GPS coordinates with from geopy.geocoders import Nominatim
and import pandas as pd
.
stop_id Lat Long
0 2 53.352280 -6.263668
1 3 53.352345 -6.263758
2 4 53.352604 -6.264143
3 6 53.352783 -6.264417
4 7 53.352867 -6.264543
5 8 53.353287 -6.265152
I have been trying to add a new column populated with the corresponding addresses to the GPS coordinates.
To do this I tried
df['address'] = geolocator.reverse((df['Lat'], df['Long']))
but got the following error message:
ValueError: Must be a coordinate pair or Point.
I then created another column [LatLong]
df['LatLong'] = df[df.columns[1:]].apply(
lambda x: ', '.join(x.dropna().astype(float).astype(str)),axis=1)
stop_id Lat Long LatLong
0 2 53.352280 -6.263668 53.35228, -6.263668
1 3 53.352345 -6.263758 53.352345, -6.263758
2 4 53.352604 -6.264143 53.352604, -6.264143
3 6 53.352783 -6.264417 53.352783, -6.264417
4 7 53.352867 -6.264543 53.352867, -6.264543
5 8 53.353287 -6.265152 53.353287, -6.265152
I then ran the the following code:
df['address'] = geolocator.reverse(df['LatLong'])
however, I just get the exact same error message.
The code I have used above is adapted from other answers on this site to similar questions and GeoPy's documentation, so I am presuming my code is not exact enough to extract the GPS coordinates in the correct way for geopy.
Can anyone point out my error to me?