Using Streamlit 1.46.1, i would like to find a way for the data_editor to return a dataframe as its currently visible in the UI.
Ie if a user shows some columns that were hidden by default i would like to be able to programmatically return the dataframe as currently seen, not the entire underlying dataframe. Finding a way to get the column headings that are currently visible would achieve the same.
# col_config is a list of column headers to display, being a subset of the headers in st.session_state('df']
if not st.session_state['df'].empty:
df = st.data_editor(
st.session_state['df'],
column_order=col_order,
column_config=col_config,
hide_index=True,
height=35*len(st.session_state['df'])+38,
disabled=True
)
st.write(df)
I would have thought that df would return the dataframe as currently seen, but it returns all the columns from the underlying dataframe, even if marked as not visible. I assume the code is in there somewhere since the download CSV button in data_editor returns the CSV as currently visualized.