Reputation: 31
While implementing the selectbox in streamlit web app it gives the following error. This is the code implemented:
st.header("Top 5 dangerous streets by affected people")
select = st.selectbox('Affected type of people', hover_data=['minute','crashes'],height=400)
if select=='Pedestrians':
st.write(original_data.query("injured_pedestrains>=1")[["on_street_name","injured_pedestrains"]].sort_values(by=['injured_pedestrains'],ascending=False).dropna(how='any')[:5])
elif select=='Cyclists':
st.write(original_data.query("injured_cyclists>=1")[["on_street_name","injured_cyclists"]].sort_values(by=['injured_cyclists'],ascending=False).dropna(how='any')[:5])
else:
st.write(original_data.query("injured_motorists>=1")[["on_street_name","injured_motorists"]].sort_values(by=['injured_motorists'],ascending=False).dropna(how='any')[:5])
if st.checkbox("Show raw data", False):
st.subheader('Raw data')
st.write(data)
error:
TypeError: SelectboxMixin.selectbox() got an unexpected keyword argument 'hover_data'
Traceback:
File "C:\Users\Sandesh Ghimire\AppData\Local\Programs\Python\Python310\lib\site-packages\streamlit\runtime\scriptrunner\script_runner.py", line 552, in _run_script
exec(code, module.__dict__)
File "D:\data-science-webapp\app.py", line 74, in <module>
select = st.selectbox('Affected type of people', hover_data=['minute','crashes'],height=400)
File "C:\Users\Sandesh Ghimire\AppData\Local\Programs\Python\Python310\lib\site-packages\streamlit\runtime\metrics_util.py", line 356, in wrapped_func
result = non_optional_func(*args, **kwargs)
Screenshot of error:
Upvotes: 0
Views: 788
Reputation: 31
Solved using st_btn_select
from st_btn_select import st_btn_select
select= st_btn_select(('Pedestrians','Cyclists','Motorists'))
Upvotes: 0