BANA409BANA409

Data App Lab

This is an in-class lab — there is nothing to submit. You build a Streamlit app for the California housing dataset, then deploy it to Streamlit Cloud, applying what you learned in the Data App Tutorial.

Setup

Download housing.csv.zip, unzip it, and move housing.csv into the my-streamlit folder from the tutorial. Create a new file app-housing.py there and run it with:

uv run streamlit run app-housing.py

Each row of housing.csv is a California district in 1990. The columns you need are:

  • latitude and longitude — the location, used by st.map()
  • median_house_value — the median house value in US dollars (from 14,999 to 500,001)
  • median_income — the median income in tens of thousands of US dollars
  • ocean_proximity — the location type: NEAR BAY, <1H OCEAN, INLAND, NEAR OCEAN, or ISLAND

Part I: Build the App

Your app needs the following, with your own name in the title:

  1. A title: California Housing Data (1990) by [Your Name].
  2. A slider labeled Minimal Median House Value that ranges from 0 to 500001 with a default of 200000. Show only the districts whose median_house_value is at least the slider value.
  3. A subheader: See more filters in the sidebar:.
  4. In the sidebar, a multiselect widget labeled Choose the location type that filters by ocean_proximity. All location types are selected by default.
  5. In the sidebar, a radio button widget labeled Choose income level with three options. Use an if statement to filter the dataframe based on the selection — see the st.radio example:
    • Low: median_income ≤ 2.5
    • Medium: 2.5 < median_income < 4.5
    • High: median_income ≥ 4.5
  6. A map of the filtered districts.
  7. Below the map, a histogram of median_house_value for the filtered districts with 30 bins.

The top of your app and the sidebar should look like this:

The title, slider, sidebar filters, and map

The map shows the filtered districts:

The map of the filtered districts

The histogram goes below the map:

Histogram of the median house value with 30 bins

Part II: Deploy the App

Deploy the app to Streamlit Cloud as a second app from the same repository, following Deploy the App in the tutorial:

  1. In GitHub Desktop, commit app-housing.py and housing.csv and click Push origin.
  2. On Streamlit Cloud, create a new app from the same repository, set the main file path to app-housing.py, and set the Python version to 3.14 under Advanced settings.

On this page