Ranking capitals by the number of Starbucks using Python and Google Maps API
I am not pretending to get the most accurate results, it is just an example. So, please don’t use it make some serious business decisions :)
The full code is available here.
First of all, let me say that Google Places API has a serious limitation of returning maximum 60 results for one search. That’s why we need to be a bit tricky. We will request it several times with different coordinates and then count a number of unique places that we got.
Probably not the best solution but it at least simple and returns more than 60 places. If you need more precise results there are lots of Google Places API wrappers around the web.
To run it by yourself you need to get a key. Don’t be afraid about money, I spent 0$ while I was testing my code.
Using this function we can create a class that searches Starbucks in the different parts of the world.
get_starbucks is just a function that makes a call to Google Places API.
Fact: 117 out of 240 capitals don’t have Starbucks at all.
Top 30 capitals by the number of Starbucks there:
Thanks for the attention to the topic, feel free to leave your questions in the comments for discussion.