-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.py
88 lines (78 loc) · 2.78 KB
/
app.py
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
import pandas as pd
import streamlit as st
from streamlit_option_menu import option_menu
from streamlit_gsheets import GSheetsConnection
from utils import preprocess_data
from views import *
# ------------------------------ Page Configuration------------------------------
st.set_page_config(page_title="CFO-Dashboard", page_icon="📊", layout="wide")
# ----------------------------------- Page Styling ------------------------------
with open("css/style.css") as css:
st.markdown(f'<style>{css.read()}</style>', unsafe_allow_html=True)
st.markdown("""
<style>
[data-testid=stHeader] {
display:none;
}
[data-testid=block-container] {
padding-top: 0px;
}
[data-testid=stSidebarUserContent]{
margin-top: -40px;
}
</style>
""", unsafe_allow_html=True)
with st.sidebar:
st.image("./assets/logo.png")
st.write("# ")
# ----------------------------------- Data Loading ------------------------------
# Create a connection object.
conn = st.connection("gsheets", type=GSheetsConnection)
balance_data = conn.read(
worksheet="Balance Sheet",
)
income_data = conn.read(
worksheet="Income DataSheet",
)
cash_data = conn.read(
worksheet="Cash Flow"
)
customers_data = conn.read(
worksheet="Customers Report"
)
sales_data = conn.read(
worksheet="Sales Report"
)
products_data = conn.read(
worksheet="Products Data"
)
market_data = conn.read(
worksheet="Market Data"
)
media_data = conn.read(
worksheet="Media Data"
)
# --------------------------- Data Pre-processing -------------------------------
customers_sales_data = pd.merge(customers_data, sales_data, on='Customer ID')
(balance_data, income_data, cash_data, customers_sales_data,
market_data, media_data) = preprocess_data([balance_data, income_data, cash_data,
customers_sales_data, market_data, media_data])
temp_df = pd.merge(income_data, balance_data, on=["Valuation Date", "Year", "Month"])
cash_flow_data = pd.merge(temp_df, cash_data, on=["Valuation Date", "Year", "Month"])
# ----------------------------------- Menu --------------------------------------
menu = option_menu(menu_title=None, menu_icon=None, orientation="horizontal",
options=["Overview", "Sales Insights", "Customer's Report",
"Demand Elasticity", "Marketing Attribution", "Accounts"])
match menu:
case "Overview":
overview(customers_sales_data, cash_flow_data)
case "Sales Insights":
sales_insights(customers_sales_data)
case "Customer's Report":
customer_report(customers_sales_data)
case "Demand Elasticity":
demand_elasticity(products_data)
case "Marketing Attribution":
marketing_attribution(market_data, media_data)
case "Accounts":
accounts(cash_flow_data)