dear boss
Please refer to the information below regarding the st.dataframe images. The first image displays all columns, the second image conceals certain columns, and the third image indicates the visibility status of the columns, which can be toggled using a checkbox. I require a list of the status of these columns, including their names and whether they are hidden or visible. Kindly advise me on how to obtain the visibility status of the st.dataframe columns.
import streamlit as st
import pandas as pd
tdf = pd.DataFrame({'A': [1000, 2000, 3000], 'B': [4000, 5000, 6000], 'C': [18, 83, 64]})
col_lst = tdf.columns.to_list()
col_lst = {col_lst[i]: True for i in range(len(col_lst))}
sc1, sc2 = st.columns((2,8), vertical_alignment='bottom')
sc1.write("Select Cols:")
for k, v in col_lst.items(): col_lst[k] = sc1.checkbox(label=k, value=v)
sc2.dataframe(tdf[[key for key, value in col_lst.items() if value]], use_container_width=False)
Sir, your code runs well; however, I would like to know how to transfer it to a new DataFrame and convert it into a list. Please guide me, as I have attempted some code but encountered errors. Kindly provide the code for transferring this selected column to a new DataFrame.
both code give me error
dddd = sc2.dataframe(tdf[[key for key, value in col_lst.items() if value]], use_container_width=False).tolist()