https://discuss.streamlit.io/t/filter-dataframe-by-selections-made-in-select-box/6627/2
Hi,
I only started using Streamlit after discovering it yesterday and have been attempting to use it to create a tool that allows users to select their geographical area from a dataframe (1st dropdown) and based on their selection select a number of general practice surgeries within the selected area (2nd dropdown). I have made a start based on the solution I have linked however I have hit a brick wall at outputing the filtered dataframe as I keep getting a value error when I run the app.
My code thus far is
import streamlit as st
import pandas as pd
st.title(“Place Based Allocation Tool”)
@st.cache
def get_data():
path = “~/Desktop/AIF/ICS Allocation Tool /gp_practice_weighted_population_by_ics v2.xlsx”
return pd.read_excel(path, 1, 0, usecols=“B,F,H,J,L,M,N:AC”)
data = get_data()
data = data.rename(columns={“Region21_7”: “Region”, “STP21_42”: “ICS”, “GP practice name”: “practice_name”})
ics = data[‘ICS’].drop_duplicates()
ics_choice = st.sidebar.selectbox(“Select your ICS:”, ics)
practices = data[“practice_name”].loc[data[“ICS”] == ics_choice]
practice_choice = st.sidebar.multiselect(“Select practices”, practices)
I’d appreciate any help whatsoever to get this working.