Spaces:
Running
Running
Pragya Jatav
commited on
Commit
·
bec3d62
1
Parent(s):
ad7f3dc
m1
Browse files
__pycache__/utilities_with_panel.cpython-310.pyc
CHANGED
Binary files a/__pycache__/utilities_with_panel.cpython-310.pyc and b/__pycache__/utilities_with_panel.cpython-310.pyc differ
|
|
pages/2_Scenario_Planner.py
CHANGED
@@ -53,7 +53,16 @@ for k, v in st.session_state.items():
|
|
53 |
# ======================= Functions ====================== #
|
54 |
# ======================================================== #
|
55 |
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
def save_ppt_file(summary_df_sorted,fig1,fig2,fig3):
|
58 |
summary_df_sorted.index = summary_df_sorted["Channel_name"]
|
59 |
# Initialize PowerPoint presentation
|
@@ -2211,48 +2220,32 @@ if auth_status == True:
|
|
2211 |
start_date1,end_date1 = first_day_of_next_year(datetime.now())
|
2212 |
# start_date1 = start_date1- relativedelta(years=1)
|
2213 |
# end_date1 = end_date1 - relativedelta(years=1)
|
2214 |
-
st.
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
|
2221 |
-
|
2222 |
-
|
2223 |
-
|
2224 |
-
|
2225 |
-
|
2226 |
-
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
|
2234 |
-
|
2235 |
-
|
2236 |
-
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
forecasted_table_df.to_excel(writer, index=True, sheet_name='Forecasted Spends')
|
2241 |
-
forecasted_table_df2.to_excel(writer, sheet_name='Monthly Breakdown',index = True)
|
2242 |
-
# Seek to the beginning of the BytesIO buffer
|
2243 |
-
excel_file.seek(0)
|
2244 |
-
return excel_file
|
2245 |
-
|
2246 |
-
st.subheader("Download Report")
|
2247 |
-
report_name = st.text_input(
|
2248 |
-
"Report name",
|
2249 |
-
key="report_input",
|
2250 |
-
placeholder="Report name",
|
2251 |
-
label_visibility="collapsed",
|
2252 |
-
)
|
2253 |
-
|
2254 |
-
|
2255 |
-
st.download_button(
|
2256 |
"Download Report",
|
2257 |
data = save_report_forecast(output_df1,output_df2),
|
2258 |
file_name = report_name+".xlsx",
|
@@ -2260,6 +2253,16 @@ if auth_status == True:
|
|
2260 |
# on_click=lambda: save_report_forecast(forecasted_table_df,report_name),
|
2261 |
disabled=len(st.session_state["report_input"]) == 0,#use_container_width=True
|
2262 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2263 |
|
2264 |
|
2265 |
|
|
|
53 |
# ======================= Functions ====================== #
|
54 |
# ======================================================== #
|
55 |
|
56 |
+
def save_report_forecast(forecasted_table_df,forecasted_table_df2):
|
57 |
+
# Convert the DataFrame to an Excel file in memory
|
58 |
+
excel_file = BytesIO()
|
59 |
+
with pd.ExcelWriter(excel_file, engine='openpyxl') as writer:
|
60 |
+
forecasted_table_df.to_excel(writer, index=True, sheet_name='Forecasted Spends')
|
61 |
+
forecasted_table_df2.to_excel(writer, sheet_name='Monthly Breakdown',index = True)
|
62 |
+
# Seek to the beginning of the BytesIO buffer
|
63 |
+
excel_file.seek(0)
|
64 |
+
return excel_file
|
65 |
+
|
66 |
def save_ppt_file(summary_df_sorted,fig1,fig2,fig3):
|
67 |
summary_df_sorted.index = summary_df_sorted["Channel_name"]
|
68 |
# Initialize PowerPoint presentation
|
|
|
2220 |
start_date1,end_date1 = first_day_of_next_year(datetime.now())
|
2221 |
# start_date1 = start_date1- relativedelta(years=1)
|
2222 |
# end_date1 = end_date1 - relativedelta(years=1)
|
2223 |
+
if st.button('Generate Forecasts'):
|
2224 |
+
st.write(f"Forecasted Spends Time Period : {start_date1.strftime('%m-%d-%Y')} to {end_date1.strftime('%m-%d-%Y')}")
|
2225 |
+
if end_date1 < start_date1 :
|
2226 |
+
st.error("End date cannot be less than start date")
|
2227 |
+
forecasted_table_df2 = pd.DataFrame()
|
2228 |
+
try:
|
2229 |
+
|
2230 |
+
st.write("Forecasted Spends wrt. Channels ")
|
2231 |
+
output_df1, output_df2 = sf.scenario_spend_forecasting(summary_df_sorted,start_date1- relativedelta(years=1),end_date1- relativedelta(years=1))
|
2232 |
+
forecasted_table_df = output_df1.copy()
|
2233 |
+
# forecasted_table_df.iloc[:2] = forecasted_table_df.iloc[:2].applymap(lambda x: "{:,.0f}".format(x))
|
2234 |
+
# forecasted_table_df.iloc[-1] = forecasted_table_df.iloc[-1].apply(lambda x: "{:.1f}%".format(x))
|
2235 |
+
st.dataframe(forecasted_table_df)
|
2236 |
+
|
2237 |
+
st.write("Monthly Breakdown Of Forecasted Spends wrt. Channels ")
|
2238 |
+
# forecasted_table_df2 = output_df2.applymap(lambda x: "{:,.0f}".format(x))
|
2239 |
+
st.dataframe(output_df2)
|
2240 |
+
|
2241 |
+
st.subheader("Download Report")
|
2242 |
+
report_name = st.text_input(
|
2243 |
+
"Report name",
|
2244 |
+
key="report_input",
|
2245 |
+
placeholder="Report name",
|
2246 |
+
label_visibility="collapsed",
|
2247 |
+
)
|
2248 |
+
st.download_button(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2249 |
"Download Report",
|
2250 |
data = save_report_forecast(output_df1,output_df2),
|
2251 |
file_name = report_name+".xlsx",
|
|
|
2253 |
# on_click=lambda: save_report_forecast(forecasted_table_df,report_name),
|
2254 |
disabled=len(st.session_state["report_input"]) == 0,#use_container_width=True
|
2255 |
)
|
2256 |
+
|
2257 |
+
except:
|
2258 |
+
st.warning("Please make sure the base data is updated")
|
2259 |
+
|
2260 |
+
|
2261 |
+
|
2262 |
+
|
2263 |
+
|
2264 |
+
|
2265 |
+
|
2266 |
|
2267 |
|
2268 |
|
summary_df.pkl
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
size 1822
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:3903995f3ab1eb9b34db90db9d8177955cff0a37af45969c97543cc82909a170
|
3 |
size 1822
|