results/format-covid-forecast/format_data_state_death_quantile.py
def load_truth_cumulative_deaths():
    """
    Load the observed cumulative deaths from the data source.
    Return A 2D dictionary structuring of <date_str, <state_id, value>>
    An example looks like:
    {
        "2020-06-17" : {
            "10": 1000,
            "11": 2000,
            ...
        },
        "2020-06-18" : {
            "10": 1100,
            "11": 2100,
            ...
        },
    }
    """
    dataset = {}
    us_death_timeseries = "us_deaths.csv"
    global_death_timeseries = "global_deaths.csv"
    with open(us_death_timeseries) as f:
        reader = csv.reader(f)
        header = next(reader, None)

        for row in reader:
            state = row[1]
            if state not in STATE_ID_MAPPING:
                continue
            state_id = STATE_ID_MAPPING[state]
            date = header[-1]
            val = int(row[-1])
            if date not in dataset:
                dataset[date] = {}

            dataset[date][state_id] = val

    with open(global_death_timeseries) as f:
        reader = csv.reader(f)
        header = next(reader, None)

        for row in reader:
            country = row[1]
            if country != "US":
                continue
            date = header[-1]
            val = int(row[-1])
            if date not in dataset:
                dataset[date] = {}

            dataset[date][country] = val

    return dataset

    Load the observed cumulative deaths from the data source.
    Return A 2D dictionary structuring of <date_str, <state_id, value>>
    An example looks like:
    {
        "2020-06-17" : {
            "10": 1000,
            "11": 2000,
            ...
        },
        "2020-06-18" : {
            "10": 1100,
            "11": 2100,
            ...
        },
    }
    
Load the observed cumulative deaths from the data source.
Load the observed cumulative deaths from the data source .
def load_truth_cumulative_deaths():
    dataset = {}
    us_death_timeseries = "us_deaths.csv"
    global_death_timeseries = "global_deaths.csv"
    with open(us_death_timeseries) as f:
        reader = csv.reader(f)
        header = next(reader, None)
        for row in reader:
            state = row[1]
            if state not in STATE_ID_MAPPING:
                continue
            state_id = STATE_ID_MAPPING[state]
            date = header[-1]
            val = int(row[-1])
            if date not in dataset:
                dataset[date] = {}
            dataset[date][state_id] = val
    with open(global_death_timeseries) as f:
        reader = csv.reader(f)
        header = next(reader, None)
        for row in reader:
            country = row[1]
            if country != "US":
                continue
            date = header[-1]
            val = int(row[-1])
            if date not in dataset:
                dataset[date] = {}
            dataset[date][country] = val
    return dataset
def load_truth_cumulative_deaths ( ) : dataset = { } us_death_timeseries = "us_deaths.csv" global_death_timeseries = "global_deaths.csv" with open ( us_death_timeseries ) as f : reader = csv . reader ( f ) header = next ( reader , None ) for row in reader : state = row [ 1 ] if state not in STATE_ID_MAPPING : continue state_id = STATE_ID_MAPPING [ state ] date = header [ - 1 ] val = int ( row [ - 1 ] ) if date not in dataset : dataset [ date ] = { } dataset [ date ] [ state_id ] = val with open ( global_death_timeseries ) as f : reader = csv . reader ( f ) header = next ( reader , None ) for row in reader : country = row [ 1 ] if country != "US" : continue date = header [ - 1 ] val = int ( row [ - 1 ] ) if date not in dataset : dataset [ date ] = { } dataset [ date ] [ country ] = val return dataset
Load the observed cumulative deaths from the data source.
Load the observed cumulative deaths from the data source .
"""
    Load the observed cumulative deaths from the data source.
    Return A 2D dictionary structuring of <date_str, <state_id, value>>
    An example looks like:
    {
        "2020-06-17" : {
            "10": 1000,
            "11": 2000,
            ...
        },
        "2020-06-18" : {
            "10": 1100,
            "11": 2100,
            ...
        },
    }
    """