Files
testing123/streamlit_dashboard/cached_function_wrappers/funding_milestones_cached_functions.py
2026-05-21 08:40:24 -04:00

29 lines
1.1 KiB
Python

from typing import List
import streamlit as st
from .shared import cached_csv_url_to_dataframe, remove_duplicate_client_records
from milestone_attribution_dataset_module import sanitize_funding_data
from constants_module import NEOSERRA_COLUMNS, OUT_COLUMNS
@st.cache_data
def cached_sanitize_funding_data(export_url:str, reportable_only:bool, allowed_centers:List[str] | None = None):
funding_df = cached_csv_url_to_dataframe(export_url)
funding_df = sanitize_funding_data(
funding_df,
col_neo_attribution_source=NEOSERRA_COLUMNS.milestone_attribution_source,
col_neo_affirmation=NEOSERRA_COLUMNS.milestone_affirmation,
col_out_documentation_level=OUT_COLUMNS.milestone_documentation_level,
col_neo_center=NEOSERRA_COLUMNS.center
)
funding_df = remove_duplicate_client_records(funding_df)
if allowed_centers is not None:
funding_df = funding_df[funding_df[NEOSERRA_COLUMNS.center].isin(allowed_centers)]
if reportable_only:
funding_df = funding_df[funding_df[NEOSERRA_COLUMNS.reportable] == 1]
return funding_df