results/format-covid-forecast/format_data_state_case_quantile.py
def add_to_dataframe(dataframe, forecast):
    """
    Given a dataframe and forecast data
    generate a pandas dataframe of incident cases.
    """
    # Write incident forecasts.
    forecast_date_str = FORECAST_DATE.strftime("%Y-%m-%d")
    for cum_week in sorted(forecast.keys()):
        target_end_date = FIRST_WEEK + ((cum_week - 1) * datetime.timedelta(7))
        target_end_date_str = target_end_date.strftime("%Y-%m-%d")
        # Terminate the loop after 8 weeks of forecasts.
        if cum_week >= 8:
            break

        # Skip forecasts before the forecast date.
        if target_end_date <= FORECAST_DATE:
            continue

        if target_end_date >= FIRST_WEEK and target_end_date.weekday() == 5:
            target = str(cum_week) + " wk ahead inc case"
            for state_id in forecast[cum_week].keys():
                for quantile in forecast[cum_week][state_id].keys():
                    if quantile == "point":
                        dataframe = dataframe.append(
                            generate_new_row(
                                forecast_date=forecast_date_str,
                                target=target,
                                target_end_date=target_end_date_str,
                                location=str(state_id),
                                type="point",
                                quantile="NA",
                                value=forecast[cum_week][state_id][quantile]
                            ), ignore_index=True)
                    else:
                        dataframe = dataframe.append(
                            generate_new_row(
                                forecast_date=forecast_date_str,
                                target=target,
                                target_end_date=target_end_date_str,
                                location=str(state_id),
                                type="quantile",
                                quantile=quantile,
                                value=forecast[cum_week][state_id][quantile]
                            ), ignore_index=True)

    return dataframe

    Given a dataframe and forecast data
    generate a pandas dataframe of incident cases.
    
Given a dataframe and forecast data
generate a pandas dataframe of incident cases.
Given a dataframe and forecast data generate a pandas dataframe of incident cases .
def add_to_dataframe(dataframe, forecast):
    forecast_date_str = FORECAST_DATE.strftime("%Y-%m-%d")
    for cum_week in sorted(forecast.keys()):
        target_end_date = FIRST_WEEK + ((cum_week - 1) * datetime.timedelta(7))
        target_end_date_str = target_end_date.strftime("%Y-%m-%d")
        if cum_week >= 8:
            break
        if target_end_date <= FORECAST_DATE:
            continue
        if target_end_date >= FIRST_WEEK and target_end_date.weekday() == 5:
            target = str(cum_week) + " wk ahead inc case"
            for state_id in forecast[cum_week].keys():
                for quantile in forecast[cum_week][state_id].keys():
                    if quantile == "point":
                        dataframe = dataframe.append(
                            generate_new_row(
                                forecast_date=forecast_date_str,
                                target=target,
                                target_end_date=target_end_date_str,
                                location=str(state_id),
                                type="point",
                                quantile="NA",
                                value=forecast[cum_week][state_id][quantile]
                            ), ignore_index=True)
                    else:
                        dataframe = dataframe.append(
                            generate_new_row(
                                forecast_date=forecast_date_str,
                                target=target,
                                target_end_date=target_end_date_str,
                                location=str(state_id),
                                type="quantile",
                                quantile=quantile,
                                value=forecast[cum_week][state_id][quantile]
                            ), ignore_index=True)
    return dataframe
def add_to_dataframe ( dataframe , forecast ) : forecast_date_str = FORECAST_DATE . strftime ( "%Y-%m-%d" ) for cum_week in sorted ( forecast . keys ( ) ) : target_end_date = FIRST_WEEK + ( ( cum_week - 1 ) * datetime . timedelta ( 7 ) ) target_end_date_str = target_end_date . strftime ( "%Y-%m-%d" ) if cum_week >= 8 : break if target_end_date <= FORECAST_DATE : continue if target_end_date >= FIRST_WEEK and target_end_date . weekday ( ) == 5 : target = str ( cum_week ) + " wk ahead inc case" for state_id in forecast [ cum_week ] . keys ( ) : for quantile in forecast [ cum_week ] [ state_id ] . keys ( ) : if quantile == "point" : dataframe = dataframe . append ( generate_new_row ( forecast_date = forecast_date_str , target = target , target_end_date = target_end_date_str , location = str ( state_id ) , type = "point" , quantile = "NA" , value = forecast [ cum_week ] [ state_id ] [ quantile ] ) , ignore_index = True ) else : dataframe = dataframe . append ( generate_new_row ( forecast_date = forecast_date_str , target = target , target_end_date = target_end_date_str , location = str ( state_id ) , type = "quantile" , quantile = quantile , value = forecast [ cum_week ] [ state_id ] [ quantile ] ) , ignore_index = True ) return dataframe
Given a dataframe and forecast data
generate a pandas dataframe of incident cases.
Given a dataframe and forecast data generate a pandas dataframe of incident cases .
"""
    Given a dataframe and forecast data
    generate a pandas dataframe of incident cases.
    """ # Write incident forecasts. # Terminate the loop after 8 weeks of forecasts. # Skip forecasts before the forecast date.
dataframe
forecast