Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ManojP96 authored Sep 11, 2023
0 parents commit f7839f4
Show file tree
Hide file tree
Showing 12 changed files with 1,961 additions and 0 deletions.
Binary file added Grammarly MMM Output for Optimization mod.xlsx
Binary file not shown.
Binary file added Grammarly MMM Output for Optimization.xlsx
Binary file not shown.
104 changes: 104 additions & 0 deletions Overview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import streamlit as st
from utilities import (set_header,
initialize_data,
load_local_css,
create_channel_summary,
create_contribution_pie,
create_contribuion_stacked_plot,
create_channel_spends_sales_plot,
format_numbers,
channel_name_formating,
load_authenticator)
import plotly.graph_objects as go
import streamlit_authenticator as stauth
import yaml
from yaml import SafeLoader
import time

st.set_page_config(layout='wide')
load_local_css('styles.css')
set_header()

for k, v in st.session_state.items():
print('printing')
print(k)
if k not in ['logout', 'login','config'] and not k.startswith('FormSubmitter'):
st.session_state[k] = v

authenticator = st.session_state.get('authenticator')

if authenticator is None:
authenticator = load_authenticator()

name, authentication_status, username = authenticator.login('Login', 'main')
auth_status = st.session_state['authentication_status']

if auth_status:
authenticator.logout('Logout', 'main')

is_state_initiaized = st.session_state.get('initialized',False)
if not is_state_initiaized:
initialize_data()
scenario = st.session_state['scenario']
raw_df = st.session_state['raw_df']
st.header('Overview of previous spends')


columns = st.columns((1,1,3))

with columns[0]:
st.metric(label = 'Spends', value=format_numbers(float(scenario.actual_total_spends)))
print(f"##################### {scenario.actual_total_sales} ##################")
with columns[1]:
st.metric(label = 'Prospects', value=format_numbers(float(scenario.actual_total_sales),include_indicator=False))


actual_summary_df = create_channel_summary(scenario)
actual_summary_df['Channel'] = actual_summary_df['Channel'].apply(channel_name_formating)

columns = st.columns((2,1))
with columns[0]:
with st.expander('Channel wise overview'):
st.markdown(actual_summary_df.style.set_table_styles(
[{
'selector': 'th',
'props': [('background-color', '#15C39A')]
},
{
'selector' : 'tr:nth-child(even)',
'props' : [('background-color', '#15C39A4D')]
}]).hide_index().to_html(), unsafe_allow_html=True)

st.markdown("<hr>",unsafe_allow_html=True)
##############################

st.plotly_chart(create_contribution_pie(scenario),use_container_width=True)
st.markdown("<hr>",unsafe_allow_html=True)



################################3
st.plotly_chart(create_contribuion_stacked_plot(scenario),use_container_width=True)
st.markdown("<hr>",unsafe_allow_html=True)
#######################################

selected_channel_name = st.selectbox('Channel', st.session_state['channels_list'] + ['non media'], format_func=channel_name_formating)
selected_channel = scenario.channels.get(selected_channel_name,None)

st.plotly_chart(create_channel_spends_sales_plot(selected_channel), use_container_width=True)

st.markdown("<hr>",unsafe_allow_html=True)

elif auth_status == False:
st.error('Username/Password is incorrect')

if auth_status != True:
try:
username_forgot_pw, email_forgot_password, random_password = authenticator.forgot_password('Forgot password')
if username_forgot_pw:
st.success('New password sent securely')
# Random password to be transferred to user securely
elif username_forgot_pw == False:
st.error('Username not found')
except Exception as e:
st.error(e)
81 changes: 81 additions & 0 deletions Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "def0e525",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 1,
"id": "6f07a1fb",
"metadata": {},
"outputs": [
{
"ename": "ModuleNotFoundError",
"evalue": "No module named 'streamlit'",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_10272\\318308029.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mstreamlit\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mst\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 2\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 3\u001b[0m \u001b[1;31m# Define the pages of your app\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 4\u001b[0m \u001b[1;32mdef\u001b[0m \u001b[0mpage1\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 5\u001b[0m \u001b[0mst\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mwrite\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"This is page 1\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
"\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'streamlit'"
]
}
],
"source": [
"import streamlit as st\n",
"\n",
"# Define the pages of your app\n",
"def page1():\n",
" st.write(\"This is page 1\")\n",
"\n",
"def page2():\n",
" st.write(\"This is page 2\")\n",
"\n",
"# Create a sidebar menu\n",
"st.sidebar.header(\"Menu\")\n",
"button1 = st.sidebar.button(\"Page 1\")\n",
"button2 = st.sidebar.button(\"Page 2\")\n",
"\n",
"# Display the selected page\n",
"if button1:\n",
" page1()\n",
"elif button2:\n",
" page2()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "751f3256",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit f7839f4

Please sign in to comment.