我正在开发用于数据科学的网络应用程序,并停留在选择框悬停数据功能上,似乎没有记录器支持悬停数据。
在 Streamlit Web 应用程序中实现选择框时,出现以下错误。 这是实现的代码:
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])
错误:
**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)**
我无法找到hover_data的确切替代方案,那么如何实现它?
使用 st_btn_select 解决
from st_btn_select import st_btn_select
select= st_btn_select(('Pedestrians','Cyclists','Motorists'))