(df)
| 5 | from config import create_region_selector |
| 6 | |
| 7 | def forecasting(df): |
| 8 | st.markdown('<h1 class="main-header">Forecast</h1>', unsafe_allow_html=True) |
| 9 | |
| 10 | selected_region = create_region_selector(df) |
| 11 | region_data = df[df['REGIONAL_OFFICE_NAME'] == selected_region] |
| 12 | available_categories = sorted(region_data['BNF_CHAPTER_PLUS_CODE'].unique()) |
| 13 | default_categories = available_categories[:8] if len(available_categories) > 8 else available_categories |
| 14 | selected_categories = st.multiselect( |
| 15 | "Choose Categories:", |
| 16 | available_categories, |
| 17 | default=default_categories |
| 18 | ) |
| 19 | |
| 20 | col1, _ = st.columns(2) |
| 21 | with col1: |
| 22 | forecast_periods = st.slider("Months to Forecast:", 1, 12, 3) |
| 23 | |
| 24 | if not selected_categories: |
| 25 | st.warning("Select at least one category.") |
| 26 | return |
| 27 | |
| 28 | line_chart = create_multi_category_forecast(region_data, selected_categories, forecast_periods) |
| 29 | st.plotly_chart(line_chart, use_container_width=True) |
| 30 | |
| 31 | forecast_insights(region_data, selected_categories, forecast_periods) |
| 32 | |
| 33 | def create_multi_category_forecast(region_data, selected_categories, forecast_months): |
| 34 | all_bnf = region_data.groupby('BNF_CHAPTER_PLUS_CODE')['TOTAL_COST'].sum() |
no test coverage detected