South Pasadena-Explore the city Through Python Programming

Ruchi Bhatt(Mrs Nitesh Nagar)
6 min readJan 26, 2021

South Pasadena — A city that you fall in love with. Located in the West San Gabriel Valley — also known as Kizh land. The original inhabitants of this land were members of Native American — HahaMog-Na-tribe — branch of Tongva Nation.

During the California Gold Rush in the mid-1800s, HahaMognas greeted Portola & the missionaries, who later established the San Gabriel Mission. The history of this city is associated with Cawston Ostrich Farm . South Pasadena is a beautiful friendly neighborhood- an oldest self builder of floats in the Tournament of Rose Parades. One of the attractions here is the gigantic Moreton Bay Fig on the west side of the city.

Historical Population of South Pasadena

Let us study the historical population of South Pasadena . The data about the historical population of the city has been extracted and read using pandas read_csv(). It is displayed as below:

In 2010 United States Census, reported that South Pasadena had a population of 25,619. The results are highlighted in green(maximum value) and red(minimum value) as below:

The bar plot of the historical population of South Pasadena is shown here. The seaborn is used here for the plotting purpose. The x axis chosen here is “Census” column and labeled as “years” . The y axis is chosen as “Pop” column and portrayed as “Population” column in the plot.

The Economy:

In this section we will analyze city’s 2015–2016 Comprehensive Annual Financial Report, and learn about the top employers in the city using Python.

Extracting the table from the websites has been increased. Copying and pasting the data line by line has been an outdated method. Here I used BeautifulSoup for Web Scraping. Web scraping is a technique which could help us transform HTML unstructured data into structed data in spreadsheet or database. By using the Beautiful soup the Wikipedia page has been parsed. We have the soup ready but in the raw HTML format. To extract the table from this soup , I used soup. find() and then read this table using pandas read_html()and converted into pandas data frame. The code is shown as below:

The above data frame has been visualized using horizontal bar plot of seaborn, where the x axis is representing number of employers and y axis is representing the name of the employers in South Pasadena.

South Pasadena Climate Details

The South Pasadena lies on 191m above sea level . In South Pasadena the winters are rainier than the summers and the climate is warm and temperate.

The average temperature in South Pasadena is 64.45 °F, Minimum Temperature in winters is 55.2 °F and the maximum temperature is 76.79 °F. This analysis was done using describe() on the data frame that provides the statistical information about the data frame.

There is a difference of 99 mm | 4 inch of precipitation between the driest and wettest months. The observation of Precipitation/Rainfall versus months is shown as below:

There is a difference of 99 mm | 4 inch of precipitation between the driest and wettest months. Suppose you have to find out the trend of climate for August — the below analysis will give you an idea on weather trends.

Cost of Living in South Pasadena, California

Cost of living indices are based on a US average of 100 in this report. A cost of living index above 100 means South Pasadena, California is more expensive and below 100 means it is cheaper.

I have dropped the columns with Nan values and a row for refining the data frame . Then plotted the data frame using matplotlib. From the above analysis we can see that South Pasadena’s cost of living is 241.1 as per the data found on the website.

Geography of South Pasadena

Let us study the geography of South Pasadena using Folium in Python. You can create beautiful, interactive maps with Python. We will generate a base map of South Pasadena by given width and height with either default tilesets or a custom tileset.

To achieve this , we will use Geocoder Python package,and Nominatim- (a geocoding software for Open Street Maps ). You know that Geopy can only make requests to Nominatim and using Nominatim, lets assume that you are the locator and your name is “The Flash” and your job is to guide us through this process. We need to establish a connection to APIs by setting up the geocoder. Lets import the geocoder and initiate it .

The latitude and longitude coordinates of South Pasadena are : 34.1133062 and -118.1478291

South Pasadena — Neighborhood

Lets make the Foursquare API call to get nearby venues and their location details. For that , lets create method named getNearByVenues(). By using the request.get(url).json(), we can get the list of venues and its coordinates and other details.

Lets define a method for finding the most visited venues in the neighborhood.

You can also plot these venues on the map using the tile”cartodpositron”

Now I have selected the tile ‘OpenstreetMap’ for displaying the venues in the South Pasadena neighborhood, with labels and markers.

The code snippet file can be found on below link:

SPAS/SouthPass.ipynb at main · ruchinagar-hue/SPAS (github.com)

If you have liked this article or have any suggestions, please leave it in the comment section.

References:

  1. https://en.wikipedia.org/wiki/South_Pasadena,_California
  2. South Pasadena climate: Average Temperature, weather by month, South Pasadena weather averages — Climate-Data.org (climate-data.org)
  3. South Pasadena, California Cost of Living (bestplaces.net)
  4. folium — Folium 0.12.1 documentation (python-visualization.github.io)

--

--