I have a series of city name in pandas dataframe. For that I need to find out the address of particular city and store them at separate column in the same dataframe. City column contain NaN values too. I am getting address for a given location / city name separately. But it is not working in a pandas dataframe
data = [['madurai',10],['NaN',12],['hosur',13]]
df = pd.DataFrame(data,columns=['Name','Age'])
from geopy.geocoders import Nominatim
geolocator = Nominatim()
for i in df.Name:
if i == "NaN":
continue
loc = geolocator.geocode(i)
address = loc.address
print(address)
It is working for the data frame but returns the last address alone and not for the entire 3 cities. If we change the order like below,
data = [['Nan',10],['Madurai',12],['hosur',13]]
df = pd.DataFrame(data,columns=['Name','Age'])
I am getting the error : GeocoderTimedOut: Service timed out
Query: 1. I want the results (address) to be saved in a column 2. How to process Nan values