San Francisco Park Reading by Juan Salamanca | Free License
Harold's company has just started a new Real Estate Investment division to provide customers with a broader range of portfolio options. Harold was tasked with building a prototype dashboard. The real estate team wants to trial this initial offering with investment opportunities for the San Francisco market. If the new service is popular, then they can start to expand to other markets.
The goal of this dashboard is to provide charts, maps, and interactive visualizations that help customers explore the data and determine if they want to invest in rental properties in San Francisco.
In this homework assignment, you will help Harold accomplish the following tasks:
- Plotly Express
- Hvplot
- Panel - Holoviz (For creating Dashboard)
- Mapbox Token
- sfo_neighborhoods_census_data.csv
- neighborhoods_coordinates.csv
- Rental Analysis Starter Jupyter Notebook
- Dashboard Starter Jupyter Notebook
The first step to building the rental analysis is to work out all of the calculations and visualizations in an analysis notebook. Use the rental_analysis.ipynb
to complete the following:
Calculate the average number of housing units per year and visualize the results as a bar chart using the Pandas plot function.
- Calculate the
average number of housing units per year
in San Fransciso
housing_unit = sfo_data.groupby('year')['housing_units'].mean()
housing_unit.plot.bar()
Visualization as a Bar chart using Pandas Plot
Visualize the average gross rent per year to better understand the trends for rental income over time. You will visualize the average (mean) gross rent per year and visualize it as a line chart.
- Calculate the mean
gross rent
for each year
sfo_data.groupby('year')['gross_rent'].mean().plot()
- Visualization as a Line Chart
Determine the average sales price per year to better understand the sales price of the rental property over time. For example, a customer will want to know if they should expect an increase or decrease in the property value over time so they can determine how long to hold the rental property.
-
Calculate the mean
sales_price_sqr_foot
for each year.sfo_data.groupby('year')['sales_price_sqr_foot'].mean().plot()
-
Visualization as a Line Chart
In this section, Compare the average prices by neighborhood.
-
Group the data by year and by neighborhood and calculate the average (mean)
sales_price_sqr_foot
.neighborhood_df = sfo_data.groupby(['year','neighborhood']).mean().reset_index() neighborhood_df.hvplot(label='Average Price per Square feet by year ', x='year', y='sale_price_sqr_foot', groupby='neighborhood')
-
Visualize with the neighborhood as a dropdown selector
-
Calculate the mean sale price for each neighborhood and then sort the values to obtain the top 10 most expensive neighborhoods on average. Plot the results as a bar chart.
avg_values_neighborhood = neighborhood_df.drop(columns=['year']).groupby('neighborhood').mean() top_expensive_neighborhood = avg_values_neighborhood.sort_values("sale_price_sqr_foot", ascending = False).head(10)
-
Visualization as a Bar Chart
Use plotly express to create parallel coordinates and parallel categories visualizations so that investors can interactively filter and explore various factors related to the sales price of the neighborhoods.
Using the DataFrame of Average values per neighborhood (calculated above), created the following visualizations:
- Parallel Coordinates Plot
- Parallel Categories Plot
Using Scatter Mapbox object from plotly express, Geographical visualization of the neighborhood location data and information about the average prices per neighborhood.
Remember that in order to create maps visualizations using Plotly Express, you will need to create an account at mapbox and create an access token.
Now that we have worked out all of the code and analysis, We will use the Panel library to build an interactive dashboard for all of the visualizations in Dashboard.ipynb
.
1. Open terminal
2. activate your envrionment where your packages are installed
3. Makesure your `MAP_KEY` added in the environment variable
4. Goto the path where the Dashboard.ipynb is located
5. Execute the below command to run the file
panel serve --show dashboard.ipynb