import streamlit as st import pandas as pd import os import base64 from pathlib import Path path = os.path.dirname(__file__) file_ = open(f"{path}/logo.png", "rb") contents = file_.read() data_url = base64.b64encode(contents).decode("utf-8") file_.close() def load_local_css(file_name): with open(file_name) as f: st.markdown(f"", unsafe_allow_html=True) def set_header(): return st.markdown( f"""

Synthetic Control

Logo
""", unsafe_allow_html=True, ) st.set_page_config(layout="wide") load_local_css("styles.css") set_header() st.title("Input data") data_file = st.file_uploader( label="Choose a file", accept_multiple_files=False, key="user_upload_file", type=["csv", "xlsx"] ) info_placeholder = st.empty() if data_file: #df = pd.read_csv(data_file,dtype = {'individual_id_ov':str}) dtype={'individual_id_ov':'str', 'past_3month_GMV_GMA':'float64', 'past_3month_qty_GMA':'int64', 'past_3month_orders_GMA':'int64', 'past_6month_GMV_GMA':'float64', 'past_6month_qty_GMA':'int64', 'past_6month_orders_GMA':'int64', 'past_9month_GMV_GMA':'float64', 'past_9month_qty_GMA':'int64', 'past_9month_orders_GMA':'int64', 'past_12month_GMV_GMA':'float64', 'past_12month_qty_GMA':'int64', 'past_12month_orders_GMA':'int64', 'avg_order_gap_between_GMA_purchases':'float64', 'days_since_last_GMA_purchase':'float64', 'age':'float64', 'gender':'str', 'income_group':'str', 'age_group':'str', 'urbanicity':'str', 'ethnicity':'str', 'Kids':'str', 'hh_size_excl_child':'str', 'hh_adult_qty':'float64', 'hh_scs_est_per1000_income_amt':'float64', 'avg_order_gap_between_WMT_purchases':'float64', 'days_since_last_WMT_purchase':'float64', 'Y':'int64'} df = pd.read_excel(data_file, sheet_name='sheet1', dtype=dtype,engine='openpyxl') st.session_state.df = df st.write(df.head()) with info_placeholder: st.success("File upload successful") plot_df=pd.read_excel(data_file, sheet_name='sheet2') st.session_state.plot_df = plot_df # start_date = st.date_input("Start date") # end_date = st.date_input("End date") # # Show the selected date range # st.write("Selected date range:", start_date, "to", end_date) # uploaded_file = st.file_uploader("Choose a file") # if uploaded_file is not None: # df=pd.read_csv(uploaded_file,dtype = {'individual_id_ov':str}) # st.session_state.df = df # st.success("File upload successful, here is the data preview") # st.write(df.head())