Hi,
I have two questions, one about how to integrate Streamlit features into my code, the other about aggregating data, but suspect they are similar and the issue lies in incorrect syntax.
I’m having difficulties making the leap from the basic examples (e.g. st.multiselect st.multiselect<!-- --> - Streamlit Docs) where everything is simple and self contained within the example to applying a concept to a real example (e.g. .csv).
I don’t understand where or how (syntax) to add the code for the awesome parts that Streamlit does, e.g. st.multiselect.
I’ve tried adding it in the basic code of my example many ways, but all as resulted in errors. When I add it below my chart, it’s not connected to my dataset (and I’ve tried all kinds of ‘dot’ connectors that pandas uses).
here is the code I’m working with.
chart_data = pd.read_csv(r'/home/mike/Environments/Streamlit/PHEV Models 2021.csv')
st.scatter_chart(
chart_data,
x='Model',
y='Range',
)
options = st.multiselect(
'Choose a Manufacturer',
['Manufacturer'], chart_data) #'Manufacturer is the first column of data in the .csv
st.write('You selected:', options)
The second question about aggregating data is somewhat related, as I believe, again, I’m not using the correct syntax, like above. I’m a bit confused when and how to use Streamlit syntax, Pandas syntax, Python syntax, etc.
I’ve tried using pandas formatting (simple ‘groupby’) but get errors. The file I’m using is a list of automobiles where each manufacturer has multiple models, I would like to group them by Manufacturer (Audi, BMW, Chevrolet, etc.), just a name (‘distinct’?), no need to do a ‘count’, and display the the average range (‘mean’) by Manufacturer. (the .csv is here GitHub - mike-ua/Streamlit-Data)
Thanks,
Mike
- running locally
- app is not deployed:
- app not on Github yet (locally only)
- Python 3.10.13, Streamlit 1.28.1