@Jessica_Smith @andfanilo @thiago @okld @vdonato @kmcgrady @Charly_Wargnier
from pandas_profiling import ProfileReport
import streamlit as st
from streamlit_pandas_profiling import st_profile_report
import pandas as pd
def describe_col(df, col):
print(df[col].unique())
def get_summary_stats(df):
with st.form(key="describe-df"):
col = st.selectbox("Select column for summary stats", df.columns)
#on clicking the stats_btn the WHOLE APP RUNS again! FIX THIS PLEASE
stats_btn = st.form_submit_button(label="Get Summary Statistics", on_click = describe_col, args=(df, col))
def file_handler():
def profiler():
file = st.session_state.upload
delim = st.session_state.choice.split(" ")[1][1:-1]
df = pd.read_csv(file, sep=delim, engine="python")
file_info = {"Filename": file.name, "FileType": file.type, "FileSize": file.size}
pr = ProfileReport(df, explorative=True)
st.write(file_info)
st_profile_report(pr)
get_summary_stats(df)
with st.form(key="file_upload"):
data_file = st.file_uploader("Upload CSV File", type=['csv'], key="upload")
seperators = [" ", "pipe (|)", r"tab (\t)", "comma (,)", "semicolon (;)"]
choice = st.selectbox("Select File Seperator", seperators, key="choice")
submit_file_btn = st.form_submit_button(label='Submit', on_click=profiler)
if __name__ =="__main__":
file_handler()
On clicking the stats_btn the whole app runs again. I donât want to do that
Furthermore, the profiler method does not work outside file handler method.
i.e. the form could be inside one function & could contain some inputs. But those inputs are locally restricted to the scope of the said function
I cannot access st.session_state.upload outside file_handler