results/format-covid-forecast/format_data_state_case.py
def load_csv(input_filename_state, input_filename_global):
    """
    Read our forecast reports and return a dictionary structuring of <date_str, <state_id, value>>
    e.g.
    {
        "2020-06-22": {
            '10': 2000.0,
            '11': 3000.0,
            ...
        },

        "2020-06-23": {
            '10': 800.0,
            '11': 900.0,
            ...
        },
        ...
    }
    """
    dataset = {}
    with open(input_filename_state) as f:
        reader = csv.reader(f)
        header = next(reader, None)

        for i in range(2, len(header)):
            date_str = header[i]
            # Initialize the dataset entry on each date.
            dataset[date_str] = {}
        
        for row in reader:
            state = row[1]
            
            # Skip the state if it is not listed in reichlab's state list.
            if state not in STATE_ID_MAPPING:
                continue

            state_id = STATE_ID_MAPPING[state]
            for i in range(2, len(header)):
                date_str = header[i]
                val = float(row[i])
                dataset[date_str][state_id] = val
                if "US" not in dataset[date_str]:
                    dataset[date_str]["US"] = 0
                dataset[date_str]["US"] += val / 2  # Average of country report and sum of state reports. 

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

        for row in reader:
            country = row[1]
            # Skip other countries.
            if not country == "US":
                continue

            for i in range(2, len(header)):
                date_str = header[i]
                val = float(row[i])
                dataset[date_str]["US"] += val / 2   # Average of country report and sum of state reports.
 
    return dataset

    Read our forecast reports and return a dictionary structuring of <date_str, <state_id, value>>
    e.g.
    {
        "2020-06-22": {
            '10': 2000.0,
            '11': 3000.0,
            ...
        },

        "2020-06-23": {
            '10': 800.0,
            '11': 900.0,
            ...
        },
        ...
    }
    
Read our forecast reports and return a dictionary structuring of >
e.g.


Read our forecast reports and return a dictionary structuring of > e . g .
def load_csv(input_filename_state, input_filename_global):
    dataset = {}
    with open(input_filename_state) as f:
        reader = csv.reader(f)
        header = next(reader, None)
        for i in range(2, len(header)):
            date_str = header[i]
            dataset[date_str] = {}
        for row in reader:
            state = row[1]
            if state not in STATE_ID_MAPPING:
                continue
            state_id = STATE_ID_MAPPING[state]
            for i in range(2, len(header)):
                date_str = header[i]
                val = float(row[i])
                dataset[date_str][state_id] = val
                if "US" not in dataset[date_str]:
                    dataset[date_str]["US"] = 0
                dataset[date_str]["US"] += val / 2  
    with open(input_filename_global) as f:
        reader = csv.reader(f)
        header = next(reader, None)
        for row in reader:
            country = row[1]
            if not country == "US":
                continue
            for i in range(2, len(header)):
                date_str = header[i]
                val = float(row[i])
                dataset[date_str]["US"] += val / 2   
    return dataset
def load_csv ( input_filename_state , input_filename_global ) : dataset = { } with open ( input_filename_state ) as f : reader = csv . reader ( f ) header = next ( reader , None ) for i in range ( 2 , len ( header ) ) : date_str = header [ i ] dataset [ date_str ] = { } for row in reader : state = row [ 1 ] if state not in STATE_ID_MAPPING : continue state_id = STATE_ID_MAPPING [ state ] for i in range ( 2 , len ( header ) ) : date_str = header [ i ] val = float ( row [ i ] ) dataset [ date_str ] [ state_id ] = val if "US" not in dataset [ date_str ] : dataset [ date_str ] [ "US" ] = 0 dataset [ date_str ] [ "US" ] += val / 2 with open ( input_filename_global ) as f : reader = csv . reader ( f ) header = next ( reader , None ) for row in reader : country = row [ 1 ] if not country == "US" : continue for i in range ( 2 , len ( header ) ) : date_str = header [ i ] val = float ( row [ i ] ) dataset [ date_str ] [ "US" ] += val / 2 return dataset
Read our forecast reports and return a dictionary structuring of <date_str, <state_id, value>>
e.g.
Read our forecast reports and return a dictionary structuring of <date_str <state_id value >> e . g .
"""
    Read our forecast reports and return a dictionary structuring of <date_str, <state_id, value>>
    e.g.
    {
        "2020-06-22": {
            '10': 2000.0,
            '11': 3000.0,
            ...
        },

        "2020-06-23": {
            '10': 800.0,
            '11': 900.0,
            ...
        },
        ...
    }
    """ # Initialize the dataset entry on each date. # Skip the state if it is not listed in reichlab's state list. # Average of country report and sum of state reports.  # Skip other countries. # Average of country report and sum of state reports.
input_filename_state
input_filename_global