Skip to content

jennyntd/Pythonic_Monopoly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Unit 6 - Pythonic Monopoly

Toronto at night

Photo by James Wheeler | Free License

Background

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, and he needs your help. The real estate team wants to trial this initial offering with investment opportunities for the Toronto market. If the new service is popular, then they can start to expand to other markets.

This dashboard's goal 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 Toronto.

In this homework assignment, you will help Harold accomplish the following tasks:

  1. Complete a notebook of rental analysis

  2. Create a dashboard of interactive visualizations to explore the market data

The data provided for this homework was retrieved from the following websites:

Note: If you encounter technical difficulties using PyViz, refer to the troubleshooting section of the PyViz Installation Guide.


Files

Instructions

Rental Analysis

The first step to building the dashboard is to work out all of the calculations and visualizations in an analysis notebook. Once the code is running properly, it can be copied over to a dashboard code and used with Panel to create the final layout. Use the rental_analysis.ipynb to complete the following:

Dwelling Types Per Year

In this section, you will calculate the number of dwelling types per year and visualize the results as a bar chart using the Pandas plot function.

Note: By default, the colour of the bar charts is blue. However, it is hard to see the difference between the yearly data.

As an optional challenge, you can manually use the color parameter of the plot() function to change the colour of each bar chart.

Default Bar Charts Colored Bar Charts
default_bar_charts colored_bar_charts

Average Monthly Shelter Costs in Toronto Per Year

In this section, you want to visualize the average monthly shelter costs per year to understand rental income trends over time better. You will visualize the average (mean) shelter cost for owned and rented dwellings per year and visualize it as line charts.

As an optional challenge, you can plot each line chart in a different colour.

  1. Calculate the average monthly shelter costs for owned and rented dwellings for each year.

  2. Visualize the monthly shelter costs per year as line charts.

    gross-rent.png

Average House Value per Year

In this section, you want to determine the average house value per year. An investor may want 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. You will visualize the average_house_value per year as a bar chart.

  1. Calculate the mean average_house_value for each year.

  2. Visualize the average_house_value per year as a line chart.

average-sales.png

Average Prices By Neighbourhood

In this section, you want to compare the house value by neighbourhood.

  1. Create a new DataFrame with the mean house values by neighbourhood per year.

  2. Visualize the mean average_house_value per year with the neighbourhood as a dropdown selector.

Hint: Use hvplot to obtain the interactive dropdown selector for the neighbourhood.

avg-price-neighbourhood.png

Number of Dwelling Types per Year

In this section, you want to visualize the number of dwelling types per year in each neighbourhood. You want to provide investors a tool to understand the evolution of dwelling types over the years.

Hint: Use hvplot to create an interactive visualization of the average number of dwelling types per year with a dropdown selector for the neighbourhood.

dwelling_types_per_year

Top 10 Most Expensive Neighbourhoods

In this section, you want to figure out which neighbourhoods are the most expensive. You will need to calculate the mean house value for each neighbourhood and then sort the values to obtain the top 10 most expensive neighbourhoods on average. Plot the results as a bar chart.

top-10-expensive-neighbourhoods.png

Neighbourhood Map

In this final section, you will read in neighbourhood location data and build an interactive map with the average prices per neighbourhood. Use a scatter Mapbox object from Plotly express to create the visualization. You will need your Mapbox API key for this.

Remember that to create maps visualizations using Plotly Express, you will need to create an account at mapbox and create an access token.

neighbourhood-map.png

Cost Analysis (Optional Challenge)

Plotly express offers a broad selection of interactive plots. In this optional challenge section, you will use Plotly express to create a couple of plots that investors can interactively filter and explore various factors related to the house value of Toronto's neighbourhoods.

  1. Create a bar chart row facet to plot the average house values for all Toronto neighbourhoods per year.

    Hint: You can learn more about facet plots in Plotly Express in this link.

    bar_chart_row

  2. Create a sunburst chart to conduct a cost analysis of the most expensive neighbourhoods in Toronto per year.

    Hint: You can learn more about sunburst charts in Plotly Express in this link.

    sunburst

Dashboard

Now that you have worked out all of the code and analysis, you will use the Panel library to build an interactive dashboard for all of the visualizations. There are no hard requirements for the layout of this dashboard, so use your imagination and creativity!

Use the dashboard.ipynb starter notebook for your dashboard code. Copy over the code for each visualization and place this into separate functions (1 function per visualization). This will make it easier to build and modify the layout later. Each function should return the plot figure in a format that Panel can use to plot the visualization.

Sample Dashboard:

dashboard-demo.gif


Submission

  • Upload two separate notebooks to Github - One for the analysis and one for the dashboard.

  • Write a README file to explain how to run and use your dashboard.

  • Submit the Github URL repository to Bootcampspot.

  • Important Note: You should not submit your Mapbox access token to Github!



Requirements

Rental Analysis (5 points)

To receive all points, your code must:
  • Calculate the number of housing units per year. (2 points)
  • Create a bar chart visualization of the rental analysis results. (3 points)

Average Monthly Shelter Costs in Toronto Per Year (10 points)

To receive all points, your code must:
  • Calculate the average monthly shelter costs for owned and rented dwellings per year. (5 points)
  • Generate line plots to show monthly shelter costs for owned and rented dwellings per year. (5 points)

Average House Value per Year (10 points)

To receive all points, your code must:
  • Calculate the average_house_value for each year. (5 points)
  • Generate a line plot using hvPlot to show the average_house_value per year. (5 points)

Average House Value by Neighbourhood (10 points)

To receive all points, your code must:
  • Create a dataFrame with the mean house values by neighbourhood per year. (5 points)
  • Create a visualization using hvPlot to show the average_house_value mean per year, adding a neighbourhood dropdown selector option. (5 points)

Number of Dwelling Types per Year (10 points)

To receive all points, your code must:
  • Use hvPlot to generate a bar chart that compares the average number of dwelling types side by side. (5 points)
  • Add a neighbourhood dropdown selector option using hvPlot. (5 points)

Top 10 Most Expensive Neighbourhoods (10 points)

To receive all points, your code must:
  • Create a DataFrame with mean house values by neighbourhood. (5 points)
  • Visualize the average_house_value per year and add a neighbourhood drop down selector. (5 points)

Neighbourhood Map (10 points)

To receive all points, your code must:
  • Create a DataFrame joining the neighbourhood location data with the average home values data. (5 points)
  • Generate an interactive map with average prices per neighbourhood. (5 points)

Interactive Toronto Dwellings Analysis Dashboard (5 points)

To receive all points, your code must:
  • Compile the visualizations from the previous analysis into functions to create a Panel dashboard. (5 points)

Optional Bonus - Cost Analysis (30 points)

To receive all bonus points, your code must:
  • Create a bar chart row facet to plot the average house values for all of Toronto's neighbourhoods per year. (10 points)
  • Create a sunburst chart to conduct a cost analysis of the most expensive neighbourhoods in Toronto per year. (10 points)

Coding Conventions and Formatting (10 points)

To receive all points, your code must:
  • Place imports at the beginning of the file, just after any module comments and docstrings and before module globals and constants. (3 points)
  • Name functions and variables with lowercase characters and with words separated by underscores. (2 points)
  • Follow Don't Repeat Yourself (DRY) principles by creating maintainable and reusable code. (3 points)
  • Use concise logic and creative engineering where possible. (2 points)

Deployment and Submission (10 points)

To receive all points, you must:
  • Submit a link to a GitHub repository that’s cloned to your local machine and contains your files. (5 points)
  • Include appropriate commit messages in your files. (5 points)

Code Comments (10 points)

To receive all points, your code must:
  • Be well commented with concise, relevant notes that other developers can understand. (10 points)

© 2021 Trilogy Education Services, a 2U, Inc. brand. All Rights Reserved.

About

Unit 6 - Pythonic Monopoly

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors