Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to extract for a list of lat/long #132

Open
systemsGit opened this issue Oct 29, 2021 · 0 comments
Open

how to extract for a list of lat/long #132

systemsGit opened this issue Oct 29, 2021 · 0 comments

Comments

@systemsGit
Copy link

systemsGit commented Oct 29, 2021

I have a data frame that consist of Store ID and its lat/lon. I want to iterate through that dataframe and for each store ID find key places nearby using the google api.

for example input:

Store-ID LAT LON
1 1.222 2.222
2 2.334 4.555
3 5.433 7.2343
Output should be (in a new dataframe):

Store-ID Places found ......
1 school
1 cafe
1 cinema
1 bookstore
.
.
.
2 toy store
2 KFC
and so on ..........

so far I have tried the following but fail to create a new data frame that would match the output format I mentioned above

map_client = googlemaps.Client(API_KEY)
theta = 0
search_string =['school','store','bank','restaurant','clothing_store','health','mosque','hospital','car_dealer','finance','electronics_store','university','home_goods_store']
distance = km_to_meters(0.1)

sc = []
business_list = []
import time
import math
for i, row in POI_copy.iterrows():
print(i, row[0], row[1], row[2])
for string in search_string:

coordinates = (row[1], row[2])
response = map_client.places_nearby(
location = coordinates,
keyword = string,
radius = distance
    )
business_list.extend(response.get('results'))
print(f'we have found a place and we are appending for store code{row[0]}')
sc.append(str(row[0]))
next_page_token = response.get('next_page_token')

while next_page_token:
    time.sleep(2)
    response = map_client.places_nearby(
    location= coordinates,
    keyword=string,
    radius=distance,
    page_token=next_page_token)
    business_list.extend(response.get('results'))
    next_page_token = response.get('next_page_token')
    print(f'we have found a place and we are appending for store code{row[0]}')
    sc.append(str(row[0]))

I also want to know if we could extract more info for each place like rating, timings, busiest hour of the day, busiest day of the week and append to the dataframe

https://stackoverflow.com/q/69744146/16447945

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant