python - How can I load and feed data from multiple excel/csv sheets into the mutliselect function? - Streamlit
问题描述
Context
In my web-app, I want my users to select different data categories and upon selecting this data category, it will load the data from its respective csv into the mutliselect function. The below demonstrates this:
So upon selection of social and Economy, load the respective data/columns from their separate excel sheets. Though I am lost on how to do this exactly.
I initially tried a for loop but it ended up creating many different multiselect columns. But this is not what I wanted. I just want the capability to load data from ‘economy’ if I click economy and if I select both ‘social’ and ‘economy’ that both datasets load. They are stored in different excel sheets.
My code as of now:
if choose_theme_category == 'Country specific':
st.write("Choose data unique to a country for this theme.")
Country_choice = st.beta_columns(3)
countries = ['','United Kingdom', 'Ireland', 'Germany']
Country = Country_choice[0].selectbox("Country", countries)
if Country == 'United Kingdom':
# Category of data
Category = st.beta_columns(4)
Data_category = Category[0].checkbox("Social")
Data_category1 = Category[1].checkbox("Economy")
Data_category2 = Category[2].checkbox("Environment")
Data_category3 = Category[3].checkbox("Health")
Data_category4 = Category[0].checkbox("Policy")
# categories = [Data_category,Data_category1,Data_category2,Data_category3,Data_category4]
data_mix_buttons = st.beta_columns([3,1,1])
# confirmation_data = data_mix_buttons[0].button("Show Data")
Hide_data = data_mix_buttons[2].checkbox("Hide Data")
# if hide data is not pressed, then show data
if not Hide_data:
# for every selection chosen, add data from their respective excel sheets
if Data_category:
Select_data = st.multiselect("Choose columns", options=COVID_19_cols,key=1)
Social_data = COVID_19_data[Select_data]
if not Select_data:
st.error("Please select at least one column.")
else:
st.write(Social_data)
Is this possible? Any suggestions?
解决方案
Solution is detailed here in the streamlit discussion website.
推荐阅读
- tensorflow - 由于 grpc 超时,tensorflow-data-validation 不适用于具有 apache-beam 直接运行器的大型数据集
- python - Django - 从逗号分隔列表创建 href 元素
- javascript - WooCommerce:更改运输区域后的消防行动
- react-native - 世博推送通知行为
- javascript - 通过对对象键的数组进行排序来创建新对象
- vb.net - 索引文本框值(来自两个文本框)
- c# - Npgsql C# - 将参数作为复合类型的数组传递到存储过程中
- windows - PowerShell 脚本太慢
- javascript - 覆盖 JS 中特定单元测试用例的 sinon 存根
- django-forms - 字段 'id' 需要一个数字,但得到了 'create'。请求方法: