Pragya Jatav commited on
Commit
b3ae5e5
·
1 Parent(s): 1581ecc

version changes

Browse files
Streamlit_functions.py CHANGED
@@ -37,6 +37,19 @@ spend_cols = ['tv_broadcast_spend',
37
  'cm_spend',
38
  'audio_spend',
39
  'email_spend']
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  metric_cols = ['tv_broadcast_grp',
41
  'tv_cable_grp',
42
  'stream_video_imp',
@@ -64,6 +77,20 @@ channels = [
64
  'DIGITAL PARTNERS',
65
  'AUDIO',
66
  'EMAIL']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  contribution_cols = [
68
  'Broadcast TV_Prospects',
69
  'Cable TV_Prospects',
@@ -877,14 +904,162 @@ def scenario_spend_forecasting(delta_df,start_date,end_date):
877
 
878
  df_modified = delta_df.merge(key_df,on = "Channel_name",how = "inner")
879
  df_modified2 = df_modified.merge(data1,on = "Channels",how ="outer")
880
- df_modified2["Forecasted Spends"] =( df_modified2["last_year_spends"]*(1+df_modified2["Delta_percent"]/100)).apply(numerize)
 
 
881
  df_modified2.index = df_modified2["Channels"]
882
- df_modified2["Spend Change"] = df_modified2["Delta_percent"]
883
- df_modified2["Last Year Spends"] = df_modified2["last_year_spends"].apply(numerize)
 
884
  df_modified3 = df_modified2[["Last Year Spends","Forecasted Spends","Spend Change"]].transpose()
885
  # df_modified2["forecasted_spends"] =
886
  # # df_modified = delta_percent
887
  # # df_modified["Optimised Spends"] = df_modified["Current Spends"]*
 
888
  return df_modified3
889
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
890
 
 
37
  'cm_spend',
38
  'audio_spend',
39
  'email_spend']
40
+ spend_cols2 = ['tv_broadcast_spend',
41
+ 'tv_cable_spend',
42
+ 'stream_video_spend',
43
+ 'olv_spend',
44
+ 'disp_prospect_spend',
45
+ 'disp_retarget_spend',
46
+ 'social_prospect_spend',
47
+ 'social_retarget_spend',
48
+ 'search_brand_spend',
49
+ 'search_nonbrand_spend',
50
+ 'cm_spend',
51
+ 'audio_spend',
52
+ 'email_spend', 'Date']
53
  metric_cols = ['tv_broadcast_grp',
54
  'tv_cable_grp',
55
  'stream_video_imp',
 
77
  'DIGITAL PARTNERS',
78
  'AUDIO',
79
  'EMAIL']
80
+ channels2 = [
81
+ 'BROADCAST TV',
82
+ 'CABLE TV',
83
+ 'CONNECTED & OTT TV',
84
+ 'VIDEO',
85
+ 'DISPLAY PROSPECTING',
86
+ 'DISPLAY RETARGETING',
87
+ 'SOCIAL PROSPECTING',
88
+ 'SOCIAL RETARGETING',
89
+ 'SEARCH BRAND',
90
+ 'SEARCH NON-BRAND',
91
+ 'DIGITAL PARTNERS',
92
+ 'AUDIO',
93
+ 'EMAIL','Date']
94
  contribution_cols = [
95
  'Broadcast TV_Prospects',
96
  'Cable TV_Prospects',
 
904
 
905
  df_modified = delta_df.merge(key_df,on = "Channel_name",how = "inner")
906
  df_modified2 = df_modified.merge(data1,on = "Channels",how ="outer")
907
+ # df_modified2["Forecasted Spends"] =( df_modified2["last_year_spends"]*(1+df_modified2["Delta_percent"]/100)).astype(int)
908
+ df_modified2["Forecasted Spends"] =( df_modified2["last_year_spends"]*(1+df_modified2["Delta_percent"]/100)).astype(int)
909
+
910
  df_modified2.index = df_modified2["Channels"]
911
+ df_modified2["Spend Change"] = df_modified2["Delta_percent"].astype(int)
912
+ # df_modified2["Forecasted Spends"] = df_modified2["Forecasted Spends"].astype(int)
913
+ df_modified2["Last Year Spends"] = df_modified2["last_year_spends"].astype(int)
914
  df_modified3 = df_modified2[["Last Year Spends","Forecasted Spends","Spend Change"]].transpose()
915
  # df_modified2["forecasted_spends"] =
916
  # # df_modified = delta_percent
917
  # # df_modified["Optimised Spends"] = df_modified["Current Spends"]*
918
+
919
  return df_modified3
920
 
921
+ def scenario_spend_forecasting2(delta_df,start_date,end_date):
922
+
923
+ key_df = pd.DataFrame()
924
+ key_df["Channel_name"] = ["Email",
925
+ "DisplayRetargeting",
926
+ "\xa0Video",
927
+ "BroadcastTV",
928
+ "SocialRetargeting",
929
+ "Connected&OTTTV",
930
+ "SearchBrand",
931
+ "Audio",
932
+ "SocialProspecting",
933
+ "CableTV",
934
+ "DisplayProspecting",
935
+ "SearchNon-brand",
936
+ "DigitalPartners"]
937
+ key_df["Channels"] = [
938
+ "EMAIL",
939
+ "DISPLAY RETARGETING",
940
+ "VIDEO",
941
+ "BROADCAST TV",
942
+ "SOCIAL RETARGETING",
943
+ "CONNECTED & OTT TV",
944
+ "SEARCH BRAND",
945
+ "AUDIO",
946
+ "SOCIAL PROSPECTING",
947
+ "CABLE TV",
948
+ "DISPLAY PROSPECTING",
949
+ "SEARCH NON-BRAND",
950
+ "DIGITAL PARTNERS"
951
+ ]
952
+
953
+ import math
954
+ start_date = pd.to_datetime(start_date)
955
+ end_date = pd.to_datetime(end_date)
956
+
957
+ cur_data = df[(df['Date'] >= start_date) & (df['Date'] <= end_date)]
958
+ cur_data = cur_data[spend_cols2]
959
+ cur_data.columns = channels2
960
+
961
+ cur_data["Date2"] = cur_data["Date"]+ pd.Timedelta(days=5)
962
+ # cur_data["Date"] = delta_df["Date"]
963
+ cur_data["Date_diff"] = (cur_data["Date"]-start_date).dt.days
964
+ cur_data["Date_diff_months"] =(np.ceil(cur_data["Date_diff"] / 30))
965
+
966
+ data2 = cur_data.groupby("Date_diff_months").agg({
967
+ 'Date':"min",
968
+ "Date2":"max"
969
+ }).reset_index()
970
+
971
+
972
+ data1 = cur_data.groupby("Date_diff_months").agg({
973
+ 'BROADCAST TV':"sum",
974
+ 'CABLE TV':"sum",
975
+ 'CONNECTED & OTT TV':"sum",
976
+ 'VIDEO':"sum",
977
+ 'DISPLAY PROSPECTING':"sum",
978
+ 'DISPLAY RETARGETING':"sum",
979
+ 'SOCIAL PROSPECTING':"sum",
980
+ 'SOCIAL RETARGETING':"sum",
981
+ 'SEARCH BRAND':"sum",
982
+ 'SEARCH NON-BRAND':"sum",
983
+ 'DIGITAL PARTNERS':"sum",
984
+ 'AUDIO':"sum",
985
+ 'EMAIL':"sum"
986
+ }).transpose()
987
+
988
+ months_list = cur_data["Date_diff_months"].unique()
989
+ data1["Channels"]=data1.index
990
+ df_modified = delta_df.merge(key_df,on = "Channel_name",how = "inner")
991
+ df_modified2 = df_modified.merge(data1,on = "Channels",how ="outer")
992
+ df_modified2.index = df_modified2["Channels"]
993
+
994
+ data3 = pd.DataFrame(index = data1.index)
995
+ for c in months_list:
996
+ data3[c] = df_modified2[c]*(1+df_modified2["Delta_percent"]/100)
997
+
998
+ df1 = df_modified2[months_list].transpose()
999
+ df1["Metrics"] = "Last Year Spends"
1000
+
1001
+ data3 = data3.transpose()
1002
+ data3 = data3.astype(int)
1003
+ data2.index = data2["Date_diff_months"]
1004
+ data2.columns = ["Date_diff_months","start date","end date"]
1005
+ data3["start date"] = data2["start date"].dt.date
1006
+ data3["end date"] = data2["end date"].dt.date
1007
+ data3["Month"] = data3.index
1008
+ cols = ["Month","start date","end date",'BROADCAST TV',
1009
+ 'CABLE TV',
1010
+ 'CONNECTED & OTT TV',
1011
+ 'VIDEO',
1012
+ 'DISPLAY PROSPECTING',
1013
+ 'DISPLAY RETARGETING',
1014
+ 'SOCIAL PROSPECTING',
1015
+ 'SOCIAL RETARGETING',
1016
+ 'SEARCH BRAND',
1017
+ 'SEARCH NON-BRAND',
1018
+ 'DIGITAL PARTNERS',
1019
+ 'AUDIO',
1020
+ 'EMAIL']
1021
+ # data3["Metrics"] = "Forecasted Year Spends"
1022
+
1023
+ # df2 = df_modified2["Delta_percent"].transpose()
1024
+ # df2["Metrics"] = "Percent Change"
1025
+ # df_modified2["last_year_spends"] =
1026
+
1027
+ # data3 = pd.DataFrame(index = data1.index)
1028
+ # for c in months_list:
1029
+ # for idx in data3.index:
1030
+ # data3[c][idx] = df_modified2[c][idx]*df_modified2["Delta_percent"]
1031
+
1032
+
1033
+ # data1 = data1[['Date',"Date2",'BROADCAST TV',
1034
+ # 'CABLE TV',
1035
+ # 'CONNECTED & OTT TV',
1036
+ # 'VIDEO','DISPLAY PROSPECTING',
1037
+ # 'DISPLAY RETARGETING',
1038
+ # 'SOCIAL PROSPECTING',
1039
+ # 'SOCIAL RETARGETING',
1040
+ # 'SEARCH BRAND',
1041
+ # 'SEARCH NON-BRAND',
1042
+ # 'DIGITAL PARTNERS',
1043
+ # 'AUDIO',
1044
+ # 'EMAIL',
1045
+ # ]]
1046
+ # data1[channels] = data1[channels].astype(int)
1047
+ # data1["Date"] = data1["Date"].dt.date
1048
+ # data1["Date2"] = data1["Date2"].dt.date
1049
+ # # pd.DataFrame(cur_data[channels].groupby("Date_diff_months").sum().transpose()).reset_index()
1050
+ # # # data1.columns = ["Channels","last_year_spends"]
1051
+
1052
+ # # df_modified = delta_df.merge(key_df,on = "Channel_name",how = "inner")
1053
+ # # df_modified2 = df_modified.merge(data1,on = "Channels",how ="outer")
1054
+ # # df_modified2["Forecasted Spends"] =( df_modified2["last_year_spends"]*(1+df_modified2["Delta_percent"]/100)).apply(numerize)
1055
+ # # df_modified2.index = df_modified2["Channels"]
1056
+ # # df_modified2["Spend Change"] = df_modified2["Delta_percent"]
1057
+ # # df_modified2["Last Year Spends"] = df_modified2["last_year_spends"].apply(numerize)
1058
+ # # df_modified3 = df_modified2[["Last Year Spends","Forecasted Spends","Spend Change"]].transpose()
1059
+ # # # df_modified2["forecasted_spends"] =
1060
+ # # # # df_modified = delta_percent
1061
+ # # # # df_modified["Optimised Spends"] = df_modified["Current Spends"]*
1062
+ # # spend_cols1 = pd.DataFrame(spend_cols)[0].to_list()
1063
+
1064
+ return data3[cols]
1065
 
__pycache__/Streamlit_functions.cpython-310.pyc CHANGED
Binary files a/__pycache__/Streamlit_functions.cpython-310.pyc and b/__pycache__/Streamlit_functions.cpython-310.pyc differ
 
pages/2_Scenario_Planner.py CHANGED
@@ -164,18 +164,18 @@ def update_sales():
164
  )
165
 
166
 
167
- def update_all_spends_abs_slider():
168
- actual_spends = _scenario.actual_total_spends
169
- if validate_input(st.session_state["total_spends_change_abs_slider"]):
170
- modified_spends = extract_number_for_string(
171
- st.session_state["total_spends_change_abs_slider"]
172
- )
173
- st.session_state["total_spends_change"] = round(
174
- ((modified_spends / actual_spends) - 1) * 100
175
- )
176
- st.session_state["total_spends_change_abs"] = numerize(modified_spends, 1)
177
 
178
- update_all_spends()
179
 
180
 
181
  # def update_all_spends_abs_slider():
@@ -1351,7 +1351,7 @@ if auth_status == True:
1351
  # )
1352
 
1353
  with st.expander("Channel Spends Simulator", expanded=True):
1354
- _columns1 = st.columns((2, 2, 1,1))
1355
  with _columns1[0]:
1356
  optimization_selection = st.selectbox(
1357
  "Optimize", options=["Media Spends", target], key="optimization_key"
@@ -1416,6 +1416,23 @@ if auth_status == True:
1416
  )
1417
 
1418
  with _columns2[2]:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1419
  min_value = round(_scenario.actual_total_spends * 0.5)
1420
  max_value = round(_scenario.actual_total_spends * 1.5)
1421
  st.session_state["total_spends_change_abs_slider_options"] = [
@@ -1449,16 +1466,19 @@ if auth_status == True:
1449
  on_change=update_sales,
1450
  )
1451
  with _columns2[2]:
1452
- st.text_input(
1453
- "Overall Lower Bound"
 
1454
  )
1455
  with _columns2[3]:
1456
- st.text_input(
1457
- "Overall Upper Bound"
 
 
1458
  )
1459
 
1460
- min_value = round(_scenario.actual_total_sales * 0.5)
1461
- max_value = round(_scenario.actual_total_sales * 1.5)
1462
  # st.write(min_value)
1463
  # st.write(max_value)
1464
  # for value in range(min_value, max_value + 1, int(100)):
@@ -1503,7 +1523,7 @@ if auth_status == True:
1503
  )
1504
 
1505
  st.markdown("""<hr class="spends-heading-seperator">""", unsafe_allow_html=True)
1506
- _columns = st.columns((2, 2.5, 1.5, 1.5, 0.5))
1507
  with _columns[0]:
1508
  generate_spending_header("Channel")
1509
  with _columns[1]:
@@ -1536,7 +1556,7 @@ if auth_status == True:
1536
  # st.write(st.session_state["scenario"].channels[channel_name].modified_total_spends)
1537
  # st.write(st.session_state["scenario"].channels[channel_name].bounds)
1538
  # st.write(st.session_state["scenario"].channels[channel_name].channel_bounds_min)
1539
- _columns = st.columns((2, 2.5, 1.5, 1.5, 0.5))
1540
  with _columns[0]:
1541
  st.write(channel_name_formating(channel_name))
1542
  bin_placeholder = st.container()
@@ -1554,11 +1574,6 @@ if auth_status == True:
1554
  # st.write(max_value)
1555
  ##print(st.session_state[channel_name])
1556
 
1557
-
1558
-
1559
-
1560
-
1561
-
1562
  _columns_min = st.columns(2)
1563
  with _columns_min[0]:
1564
  spend_input = st.text_input(
@@ -1622,14 +1637,37 @@ if auth_status == True:
1622
  current_channel_spends
1623
  )
1624
  st.session_state["acutual_predicted"]["Delta"].append(spends_delta)
1625
- ## REMOVE
1626
- st.metric(
1627
- "Spends",
1628
- format_numbers(current_channel_spends),
1629
- delta=numerize(spends_delta, 1),
1630
- label_visibility="collapsed",
1631
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1632
 
 
 
 
 
 
 
 
 
1633
  with _columns[3]:
1634
  # sales
1635
  current_channel_sales = float(_channel_class.modified_total_sales)
@@ -1638,13 +1676,38 @@ if auth_status == True:
1638
  st.session_state["acutual_predicted"]["Old_sales"].append(actual_channel_sales)
1639
  st.session_state["acutual_predicted"]["New_sales"].append(current_channel_sales)
1640
  #st.write(actual_channel_sales)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1641
 
1642
- st.metric(
1643
- target,
1644
- format_numbers_f(current_channel_sales),
1645
- delta=numerize(sales_delta, 1),
1646
- label_visibility="collapsed",
1647
- )
 
 
1648
 
1649
  with _columns[4]:
1650
 
@@ -1866,7 +1929,10 @@ if auth_status == True:
1866
  end_date1 = current_date + relativedelta(months = 12)- relativedelta(years=1)
1867
 
1868
  forecasted_table_df = sf.scenario_spend_forecasting(summary_df_sorted,start_date1,end_date1)
1869
- st.table(forecasted_table_df)
 
 
 
1870
 
1871
  st.markdown("""
1872
  <style>
@@ -1880,24 +1946,16 @@ if auth_status == True:
1880
  </style>
1881
  """, unsafe_allow_html=True)
1882
 
1883
- def save_report_forecast(forecasted_table_df):
1884
  from io import BytesIO
1885
- # excel_file_path = filename+ '.xlsx'
1886
- # forecasted_table_df.to_excel(excel_file_path, index=False)
1887
-
1888
  # Convert the DataFrame to an Excel file in memory
1889
  excel_file = BytesIO()
1890
  with pd.ExcelWriter(excel_file, engine='openpyxl') as writer:
1891
- forecasted_table_df.to_excel(writer, index=False, sheet_name='Sheet1')
1892
-
1893
  # Seek to the beginning of the BytesIO buffer
1894
  excel_file.seek(0)
1895
  return excel_file
1896
- # message_container = st.empty()
1897
- # with message_container:
1898
- # st.write(f'<div class="yellow-container">{"Report Saved!"}</div>', unsafe_allow_html=True)
1899
- # time.sleep(5)
1900
- # st.empty()
1901
 
1902
  st.subheader("Download Report")
1903
  report_name = st.text_input(
@@ -1910,7 +1968,7 @@ if auth_status == True:
1910
 
1911
  st.download_button(
1912
  "Download Report",
1913
- data = save_report_forecast(forecasted_table_df),
1914
  file_name = report_name+".xlsx",
1915
  mime="application/vnd.ms-excel",
1916
  # on_click=lambda: save_report_forecast(forecasted_table_df,report_name),
 
164
  )
165
 
166
 
167
+ # def update_all_spends_abs_slider():
168
+ # actual_spends = _scenario.actual_total_spends
169
+ # if validate_input(st.session_state["total_spends_change_abs_slider"]):
170
+ # modified_spends = extract_number_for_string(
171
+ # st.session_state["total_spends_change_abs_slider"]
172
+ # )
173
+ # st.session_state["total_spends_change"] = round(
174
+ # ((modified_spends / actual_spends) - 1) * 100
175
+ # )
176
+ # st.session_state["total_spends_change_abs"] = numerize(modified_spends, 1)
177
 
178
+ # update_all_spends()
179
 
180
 
181
  # def update_all_spends_abs_slider():
 
1351
  # )
1352
 
1353
  with st.expander("Channel Spends Simulator", expanded=True):
1354
+ _columns1 = st.columns((1.5, 1.5, 1,1))
1355
  with _columns1[0]:
1356
  optimization_selection = st.selectbox(
1357
  "Optimize", options=["Media Spends", target], key="optimization_key"
 
1416
  )
1417
 
1418
  with _columns2[2]:
1419
+ overall_lower_bound = st.number_input(
1420
+ "Overall Lower Bound for Spends",
1421
+ value = 50
1422
+ # key = overall_lower_bound,
1423
+ # on_change=partial(update_data_bound_min_overall)
1424
+ )
1425
+ with _columns2[3]:
1426
+ overall_upper_bound = st.number_input(
1427
+ "Overall Upper Bound for Spends",
1428
+ value = 50
1429
+ # key = overall_upper_bound,
1430
+ # on_change=partial(update_data_bound_max_overall)
1431
+ )
1432
+
1433
+
1434
+
1435
+
1436
  min_value = round(_scenario.actual_total_spends * 0.5)
1437
  max_value = round(_scenario.actual_total_spends * 1.5)
1438
  st.session_state["total_spends_change_abs_slider_options"] = [
 
1466
  on_change=update_sales,
1467
  )
1468
  with _columns2[2]:
1469
+ overall_lower_bound = st.number_input(
1470
+ "Overall Lower Bound for Spends",
1471
+ value = 50
1472
  )
1473
  with _columns2[3]:
1474
+
1475
+ overall_upper_bound = st.number_input(
1476
+ "Overall Upper Bound for Spends",
1477
+ value = 50
1478
  )
1479
 
1480
+ min_value = round(_scenario.actual_total_sales * (1-overall_lower_bound/100))
1481
+ max_value = round(_scenario.actual_total_sales * (1+overall_upper_bound/100))
1482
  # st.write(min_value)
1483
  # st.write(max_value)
1484
  # for value in range(min_value, max_value + 1, int(100)):
 
1523
  )
1524
 
1525
  st.markdown("""<hr class="spends-heading-seperator">""", unsafe_allow_html=True)
1526
+ _columns = st.columns((1.5,2.5,2,2, 1))
1527
  with _columns[0]:
1528
  generate_spending_header("Channel")
1529
  with _columns[1]:
 
1556
  # st.write(st.session_state["scenario"].channels[channel_name].modified_total_spends)
1557
  # st.write(st.session_state["scenario"].channels[channel_name].bounds)
1558
  # st.write(st.session_state["scenario"].channels[channel_name].channel_bounds_min)
1559
+ _columns = st.columns((1.5,2.5,2,2, 1))
1560
  with _columns[0]:
1561
  st.write(channel_name_formating(channel_name))
1562
  bin_placeholder = st.container()
 
1574
  # st.write(max_value)
1575
  ##print(st.session_state[channel_name])
1576
 
 
 
 
 
 
1577
  _columns_min = st.columns(2)
1578
  with _columns_min[0]:
1579
  spend_input = st.text_input(
 
1637
  current_channel_spends
1638
  )
1639
  st.session_state["acutual_predicted"]["Delta"].append(spends_delta)
1640
+ _spend_cols = st.columns(2)
1641
+ with _spend_cols[0]:
1642
+ st.metric(
1643
+ label="Actual Spends",
1644
+ value=format_numbers(actual_channel_spends),
1645
+ # delta=numerize(spends_delta, 1),
1646
+ # label_visibility="collapsed",
1647
+ )
1648
+
1649
+ st.metric(
1650
+ label="Change",
1651
+ value= format_numbers_f(spends_delta),
1652
+ delta=numerize(spends_delta, 1),
1653
+ # label_visibility="collapsed",
1654
+ )
1655
+ with _spend_cols[1]:
1656
+ st.metric(
1657
+ label="Simulated Spends",
1658
+ value=format_numbers(current_channel_spends),
1659
+ # delta=numerize(spends_delta, 1),
1660
+ # label_visibility="collapsed",
1661
+ )
1662
 
1663
+ st.metric(
1664
+ label="Percent Change",
1665
+ value= numerize(( spends_delta/actual_channel_spends)*100,0) +"%",
1666
+ delta=numerize(spends_delta, 1),
1667
+ # label_visibility="collapsed",
1668
+ )
1669
+
1670
+
1671
  with _columns[3]:
1672
  # sales
1673
  current_channel_sales = float(_channel_class.modified_total_sales)
 
1676
  st.session_state["acutual_predicted"]["Old_sales"].append(actual_channel_sales)
1677
  st.session_state["acutual_predicted"]["New_sales"].append(current_channel_sales)
1678
  #st.write(actual_channel_sales)
1679
+
1680
+ _prospect_cols = st.columns(2)
1681
+ with _prospect_cols[0]:
1682
+ st.metric(
1683
+ # target,
1684
+ label="Actual Prospects",
1685
+ value= format_numbers_f(actual_channel_sales),
1686
+ # delta=numerize(sales_delta, 1),
1687
+ # label_visibility="collapsed",
1688
+ )
1689
+ st.metric(
1690
+ label="Change",
1691
+ value= format_numbers_f(_channel_class.delta_sales),
1692
+ delta=numerize(sales_delta, 1),
1693
+ # label_visibility="collapsed",
1694
+ )
1695
+ with _prospect_cols[1]:
1696
+ st.metric(
1697
+ label="Simulated Prospects",
1698
+ value= format_numbers_f(current_channel_sales),
1699
+ # delta=numerize(sales_delta, 1),
1700
+ # label_visibility="collapsed",
1701
+ )
1702
 
1703
+ st.metric(
1704
+ label="Percent Change",
1705
+ value= numerize((_channel_class.delta_sales/actual_channel_sales)*100,0) +"%",
1706
+ delta=numerize(sales_delta, 1),
1707
+ # label_visibility="collapsed",
1708
+ )
1709
+
1710
+
1711
 
1712
  with _columns[4]:
1713
 
 
1929
  end_date1 = current_date + relativedelta(months = 12)- relativedelta(years=1)
1930
 
1931
  forecasted_table_df = sf.scenario_spend_forecasting(summary_df_sorted,start_date1,end_date1)
1932
+ st.dataframe(forecasted_table_df)
1933
+
1934
+ forecasted_table_df2 = sf.scenario_spend_forecasting2(summary_df_sorted,start_date1,end_date1)
1935
+ st.dataframe(forecasted_table_df2)
1936
 
1937
  st.markdown("""
1938
  <style>
 
1946
  </style>
1947
  """, unsafe_allow_html=True)
1948
 
1949
+ def save_report_forecast(forecasted_table_df,forecasted_table_df2):
1950
  from io import BytesIO
 
 
 
1951
  # Convert the DataFrame to an Excel file in memory
1952
  excel_file = BytesIO()
1953
  with pd.ExcelWriter(excel_file, engine='openpyxl') as writer:
1954
+ forecasted_table_df.to_excel(writer, index=True, sheet_name='Forecasted Spends')
1955
+ forecasted_table_df2.to_excel(writer, index=False, sheet_name='Monthly Breakdown')
1956
  # Seek to the beginning of the BytesIO buffer
1957
  excel_file.seek(0)
1958
  return excel_file
 
 
 
 
 
1959
 
1960
  st.subheader("Download Report")
1961
  report_name = st.text_input(
 
1968
 
1969
  st.download_button(
1970
  "Download Report",
1971
+ data = save_report_forecast(forecasted_table_df,forecasted_table_df2),
1972
  file_name = report_name+".xlsx",
1973
  mime="application/vnd.ms-excel",
1974
  # on_click=lambda: save_report_forecast(forecasted_table_df,report_name),
summary_df.pkl CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b1c5355ea93c754c8f7eee9dca0242123d67190ebe0468dec482dc4931a4449b
3
  size 1822
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2cdad2e46bd5810d3a714d9ef98b7644d6f5cdd61a62b160d3a1dd48b8bf9aec
3
  size 1822