Viktor Ivanenko














Sign up
Beta
Spinner

Where to open a new coffee shop?

📖 Background

You are helping a client who owns coffee shops in Colorado. The company's coffee shops serve high-quality and responsibly sourced coffee, pastries, and sandwiches. They operate three locations in Fort Collins and want to expand into Denver.

Your client believes that the ideal location for a new store is close to affluent households, and the store appeals to the 20-35 year old demographic.

Your team collected geographical and demographic information about Denver's neighborhoods to assist the search. They also collected data for Starbucks stores in Denver. Starbucks and the new coffee shops do not compete for the same clients; the team included their location as a reference.

1. ETL.

💾 1.1. The data.

You have assembled information from three different sources (locations, neighborhoods, demographics):

Starbucks locations in Denver, Colorado
  • "StoreNumber" - Store Number as assigned by Starbucks
  • "Name" - Name identifier for the store
  • "PhoneNumber" - Phone number for the store
  • "Street 1, 2, and 3" - Address for the store
  • "PostalCode" - Zip code of the store
  • "Longitude, Latitude" - Coordinates of the store
Neighborhoods' geographical information
  • "NBHD_ID" - Neighborhood ID (matches the census information)
  • "NBHD_NAME" - Name of the statistical neighborhood
  • "Geometry" - Polygon that defines the neighborhood
Demographic information
  • "NBHD_ID" - Neighborhood ID (matches the geographical information)
  • "NBHD_NAME' - Nieghborhood name
  • "POPULATION_2010' - Population in 2010
  • "AGE_ " - Number of people in each age bracket (< 18, 18-34, 35-65, and > 65)
  • "NUM_HOUSEHOLDS" - Number of households in the neighborhood
  • "FAMILIES" - Number of families in the neighborhood
  • "NUM_HHLD_100K+" - Number of households with income above 100 thousand USD per year

Starbucks locations were scrapped from the Starbucks store locator webpage by Chris Meller.
Statistical Neighborhood information from the City of Denver Open Data Catalog, CC BY 3.0 license.
Census information from the United States Census Bureau. Publicly available information.

%%capture
pip install geopandas
%%capture
pip install contextily
#dependencies
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
import folium
import contextily as ctx
from shapely.geometry import shape

denver = pd.read_csv('./data/denver.csv')
denver
neighborhoods = gpd.read_file('./data/neighborhoods.shp')
neighborhoods
census = pd.read_csv('./data/census.csv')
census

1.2. Cleaning and transforming the data.

denver = denver.fillna(' ')
census_d = census.drop(['AGE_LESS_18','AGE_35_TO_65','AGE_65_PLUS'], axis=1)
display(census_d.head(), census_d.shape)
neigh_census = pd.merge(neighborhoods, census_d, on=['NBHD_ID', 'NBHD_NAME'])
display(neigh_census.head())

display(neigh_census.isna().sum())
neigh_census_aff = neigh_census.dropna()
display("Affluent households (income +100k USD per year) only:", neigh_census_aff.head(), neigh_census_aff.shape)

2. Geospatial Data Visualisation.

2.1. Visualisation of Population.

ax = neigh_census.plot(column='POPULATION_2010', figsize=(15,20), cmap='Reds', legend=True, legend_kwds={'shrink': 0.35}, alpha=0.5)
plt.title("Denver's Neighborhoods Population")
ax.set_axis_off()

ax1 = plt.scatter(x=denver['Longitude'], y=denver['Latitude'], c='white', edgecolor = 'green')
ctx.add_basemap(ax, crs='EPSG:4326')

plt.show()



  • AI Chat
  • Code