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.