Home | Python tài chính | Compare the most common places between New York and Toronto
Table of Contents
- Introduction: Business Problem
- Data
- Methodology
- Analysis
- Results and Discussion
- Conclusion
Introduction
- In this project, I will compare the similarity/dissimilarity between the two cities: New York and Toronto.
- I will try to find what are the top 10 most common venues in each neighborhood of each city
- This finding will help people determine which is the best place to visit, study, or do business.
- I will use Python and Foursquare API to assist my analysis.
Data
Data Sources
Below are data sources for my analysis:
- New York City https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DS0701EN-SkillsNetwork/labs/newyork_data.json
- Toronto City https://en.wikipedia.org/wiki/List_of_postal_codes_of_Canada:_M
Data Processing
For New York data
I get the json file from the server https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/IBMDeveloperSkillsNetwork-DS0701EN-SkillsNetwork/labs/newyork_data.json. Then, I transformed the data into a dataframe using pandas library.
After that, I looped through the data and fill the dataframe one row at a time. Below is the output of the 5 rows of the dataframe:

For Toronto data
I did the slightly different processing. The first difference was that I used BeautifulSoup library to scape data from https://en.wikipedia.org/wiki/List_of_postal_codes_of_Canada:_M for Toronto city.
Another different was that, Toronto data has some “Not assigned” inputs in the Borough column, and I need to remove them.
Here is the dataset before removing “Not assigned” in the Borough column.

After removing “Not assigned” in the Borough column

I grouped the data by “PostalCode”

Since, the latitude and longitude of Toronto data are not available in the above data. I need to get the those coordinates from https://cocl.us/Geospatial_data.

Then, I merged those two datasets to get a new dataframe with columns: “Borough”, “Neighborhood”, “Latitude”, and “Longitude” same as New York data.
Lastly, since the original data contains many boroughs in Canada, but we only want data for Toronto. So that I sliced the data to get information for Toronto only.

Analysis
I created a map of New York and Toronto to get an overview of the two cities using the latitudes and longitudes values.
New York

Toronto

Then, I did some processing to get nearby venues for each neighborhood in each city. There are 470 unique categories for New York city and 280 unique categories for Toronto.
Below is the first few rows of nearby venues after grouping by “Neighborhood” column.
New York

Toronto

I then created a dataframe and show the top 10 most common venues of each neighborhood in New York and Toronto. Below is the summary of the first 5 rows of the top 10 common places.
New York

Toronto

Next step, I clustered the above data into 5 different clusters, and below is the summary of the first 5 rows:
New York

Toronto

Results and Discussions
From the above analysis, I found the most common venues of New York and Toronto are as follows:
New York

Toronto

Discussion
Based on our analysis on the data, I summarized the top 10 most common venues in the city of New York and Toronto.
I found that New York city is more diverse compared to Toronto. While the most common venues of New York are diverse including restaurants, coffee shop, beach, bar, sport places, Art gallery, Theater,…, the most common venues of Toronto are pub, restaurant, coffee shop, park, Harbor.
This finding is interesting because it is a useful guide for travelers who want to travel to those cities. Or, it is also useful for businessmen, for example: to decide whether they should open a new Italian or Indian restaurant in Toronto, …
This analysis also provides an idea for those who want to decide which city to live, study, or do business.
For those who prefer a multicultural city, then New York would be a better choice.
Conclusion
This analysis mainly focuses on finding most common places in New York and Toronto cities, and compare the most common places between the two cities. Also, it will help people to decide which city to visit, study or do business…
