I have a dataset that contains 750,000 rows. I want to query each row and get the postcodes using the latitudes and longitudes.
Problem:
The code is executing very fast when I query like 100 rows, and it takes like 10min to query 1000 rows. But, when I try to query like 10,000 rows, it takes hours.
Question(s):
Is there any way I can speed up the querying so that the code will execute faster?
OR
Is there any new approach I can take to get a quicker and accurate result?
My code:
#new_df = green_taxi_fare_df.copy()[:20000]
from geopy.geocoders import Nominatim
postcodes = []
geolocator = Nominatim(user_agent = "app_name")
for index, row in new_df.iterrows():
row_location = geolocator.reverse(f"{row['Pickup_latitude']}, {row['Pickup_longitude']}", timeout = 10)
postcode = row_location.raw['address']['postcode'] if 'postcode' in row_location.raw['address'] else '00000'
postcodes.append(postcode)
new_df['start_postcode'] = postcodes
new_df
defined? \$\endgroup\$folium
but not using it in the code you provided. Is it possible your actual code looks quite different? \$\endgroup\$