Ejemplo n.º 1
0
def now(config=None):

    # Import cases
    df = get_states_cases.now(config, "br")
    df["last_updated"] = pd.to_datetime(df["last_updated"])

    return get_rt(df, "state_num_id", config)
Ejemplo n.º 2
0
def now(config):
    """Data & states' indicators for FarolCovid app, keeping past records."""

    # adapted from endpoints.get_states_farolcovid_main.now()

    # NOTE: this version do not include health resources and capacity data,
    # as these indicators come from a source that do not track historical data

    df = pd.DataFrame()

    # get full record of case counts for brazilian states
    cases_latest = get_states_cases.now(config)
    cases_latest["last_updated"] = pd.to_datetime(cases_latest["last_updated"])

    # population by state (fixed)
    population_df = _get_population_by_state(config)

    # iterate over each date since the first case (Feb. 25th, 2020)
    for date in _daterange(pd.Timestamp(2020, 2, 25), pd.Timestamp.today()):
        cases_until_then = (
            cases_latest.loc[cases_latest["last_updated"] <= date, :])

        df_partial = get_situation_indicators(
            population_df,
            data=cases_until_then,
            place_id="state_num_id",
            rules=config["br"]["farolcovid"]["rules"],
            classify="situation_classification",
        )

        try:
            df_partial = get_control_indicators(
                df_partial,
                data=get_rt(cases_until_then, "state_num_id", config),
                place_id="state_num_id",
                rules=config["br"]["farolcovid"]["rules"],
                classify="control_classification",
            )
        except ValueError:
            # raised when at least one of the states have no record in the last
            # ten days (specially in the beginning of the epidemics)
            pass

        df_partial = get_trust_indicators(
            df_partial,
            data=cases_until_then,
            place_id="state_num_id",
            rules=config["br"]["farolcovid"]["rules"],
            classify="trust_classification",
        )

        # alert classification
        cols = [col for col in df_partial.columns if "classification" in col]
        df_partial["overall_alert"] = df_partial.apply(
            lambda row: get_overall_alert(row[cols]), axis=1)

        # add to historical data
        df = pd.concat([df, df_partial], ignore_index=True)

    return df_partial
Ejemplo n.º 3
0
def now(config=None):

    # Import cases
    df = get_health_region_cases.now(config, "br")
    df["last_updated"] = pd.to_datetime(df["last_updated"])

    return get_rt(df, "health_region_id", config)
Ejemplo n.º 4
0
def now(config=None):
    # TODO: mudar para get_[cities/region/states]_cases quando tiver as tabelas
    return get_cities_rt.get_rt(get_states_cases.now(),
                                place_id="state_num_id")
Ejemplo n.º 5
0
def now(config=None):
    return get_cities_rt.get_rt(get_health_region_cases.now(),
                                place_id="health_region_id")