Battle of neighborhoods

Daniel Mlabwa
5 min readJun 7, 2021

Well, this is submitted as part of my IBM Capstone Project. The work has been pending since 2019 and it’s high time I felt that I should just finish it

Disclaimer: The quality of work and data may not be the best but I hope you’ll get the concept

Background/problem:

Finding places for attraction and chilling can be a bit not easy in Dar es Salaam, Tanzania. The city, however, has so much to offer and one may need some guidance in order to make sure that. In Dar es Salaam, one has to know where exactly they intend to go then search for that place. I believe, this should not be the case and one has be able to easily see all the available locations for refreshing before they can commute to such places

In order to solve that challenge, especially for visitors, I intended to create a simple solution in which a person can be able to view all the list of available locations (grouped by category) and if need be can also be able to view all the places within each district and the category it falls on in order to assist them with planning the entertainment and refreshments

Data used:

The data used mostly originated from Foursquare API, where the names and categories of places were extracted. Such data was then combined/distributed into the five districts of Dar es Salaam in order to further narrow down and filter the search for various places. The list of districts of Dar es Salaam can be accessed from http://www.dsm.go.tz/ (under ‘Wilaya’ dropdown menu) which is the website of the Regional Commissioner of Dar es Salaam

Methodology:

The first step was creating and loading a csv that contains all the district names to my Notebook. I did that by using the pandas library from Python. Later on I used the Nominatim library (imported from geopy.encoders) in order to get the geographical position of each of the districts. This was one of the important steps, since when I started to work on the data at first I realised there was another place in Nigeria that had a similar name as one of the districts of Dar es Salaam (Ilala). I then scrapped some of the information that was not important from the dataframe in order to have a clean dataframe

Just to be sure of the location picked by the geopy package, I then plotted a map showing the centre points of each of the districts. This gave me confidence on the specific location that I am dealing with

From there I used the Foursquare API data to get location within 10km radius for Ilala district as a base reference to test whether the data are pulling. I then ran head() on the dataframe in order to get at least the 5 first elements of the data as follows

Next, I created a grouping for these places based on their category for each district within Dar es Salaam. First, summarised my search of categories to Museums and Restaurants in order to have at least a picture of the categories that are available for each location

Later on I did the grouping for that specific category (Restaurants) in order to have an overview of how many restaurants each district has

This helped me to be sure of the categories pulled from each district at a radius of 10km from the focal point

Results:

Results were as follows, where depending on the category that a person chooses, the list of all places in Dar es Salaam, and the district in which they belong to is populated and a specific category related to it is appended on the given list

The same can be applied to various other categories such as Museum and Beach as follows:

For beach category:

Discussion:

One of the main challenges that I have observed is on the quality of data and information pulled from the Foursquare API. Most of it does not seem very clean as compared to the real locations of some of the places. It can be debated whether the radius used may be too broad but that may need further analysis to prove it. On the quality of tools, I used Anaconda Navigator to launch Jupyterlab on a Lenovo X270 and the execution was very smooth

Conclusion:

A comprehensive list of places, based on their categories and location in which they are found in Dar es Salaam, was extracted and present the user a great dynamic and options when thinking of planning their stays in Dar es Salaam

--

--