File size: 2,968 Bytes
a9415a6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
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"<style>{f.read()}</style>", unsafe_allow_html=True)

def set_header():
    return st.markdown(
        f"""<div class='main-header'>
                    <h1>Synthetic Control</h1>
                    <img src="data:image;base64,{data_url}", alt="Logo">
            </div>""",
        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())