Last active
September 22, 2020 09:31
-
-
Save gbarreiro/a7e94cc7332bda25ec182370d462b7af to your computer and use it in GitHub Desktop.
Best cuisines: get the number of restaurants for each cuisine on each city
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
restaurants = pd.DataFrame(columns=['City', 'Cuisine', 'Number of restaurants']) # define the DataFrame where the results will be stored | |
for city in cities: | |
for cuisine_name, category_id in cuisines.items(): | |
# For each city, retrieve the top restaurants from Foursquare for each cuisine... | |
query = requests.get("{url}&near={city}&categoryId={category_id}".format(url=URL, city=city, category_id=category_id)) | |
if query.status_code == 200: | |
number = query.json() | |
restaurants = restaurants.append({ | |
'City': city, | |
'Cuisine': cuisine_name, | |
'Number of restaurants': number | |
}, ignore_index=True) | |
restaurants # print the results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment