results/fetch_forecasts_script/fetch_forecasts.py
def write_report(self, model_name, forecast_date, observed, predicted):
        """ 
        Given a dataset of observed deaths, 
        a dataset of forecast deaths, the model'sname and a forecast date.
        Write down the report into csv form. 
        """
        columns = ['State']
        columns.append((forecast_date - self.costant.DAY_ZERO).days)

        for date_str in predicted[self.costant.STATES[0]]:
            date = datetime.datetime.strptime(date_str,"%Y-%m-%d")
            # Skip if the target end day is not Saturday.
            if (date.weekday() != 5):
                continue
            columns.append((datetime.datetime.strptime(date_str,"%Y-%m-%d") - self.costant.DAY_ZERO).days)
        dataframe = pd.DataFrame(columns=columns)
        
        for state in self.costant.STATES:
            new_row = {}
            new_row["State"] = state
            # Write the first column, observed cumulative deaths on the forecast date. 
            if state in observed:
                new_row[(forecast_date - self.costant.DAY_ZERO).days] = observed[state][forecast_date.strftime("%Y-%m-%d")]
            else:
                new_row[(forecast_date - self.costant.DAY_ZERO).days] = "NaN"

            # Write the incident deaths for the following two weeks.
            for date_str in predicted[self.costant.STATES[0]]:
                date = datetime.datetime.strptime(date_str,"%Y-%m-%d")
                # Skip if the target end day is not Saturday.
                if (date.weekday() != 5):
                    continue
                if state in predicted and date_str in predicted[state]:
                    new_row[(date - self.costant.DAY_ZERO).days] = predicted[state][date_str]
                else:
                    new_row[(date - self.costant.DAY_ZERO).days] = "NaN"

            dataframe = dataframe.append(new_row, ignore_index=True)
            
        output_name = model_name + '_' + str((forecast_date - self.costant.DAY_ZERO).days) + ".csv"
        output_name = output_name.replace('-', '_')
        dataframe.to_csv(self.output_directory + output_name)
        print(output_name + " has been written.")
 
        Given a dataset of observed deaths, 
        a dataset of forecast deaths, the model'sname and a forecast date.
        Write down the report into csv form. 
        
Given a dataset of observed deaths,
a dataset of forecast deaths, the model'sname and a forecast date.
Write down the report into csv form.
Given a dataset of observed deaths a dataset of forecast deaths the model ' sname and a forecast date . Write down the report into csv form .
def write_report(self, model_name, forecast_date, observed, predicted):
        columns = ['State']
        columns.append((forecast_date - self.costant.DAY_ZERO).days)
        for date_str in predicted[self.costant.STATES[0]]:
            date = datetime.datetime.strptime(date_str,"%Y-%m-%d")
            if (date.weekday() != 5):
                continue
            columns.append((datetime.datetime.strptime(date_str,"%Y-%m-%d") - self.costant.DAY_ZERO).days)
        dataframe = pd.DataFrame(columns=columns)
        for state in self.costant.STATES:
            new_row = {}
            new_row["State"] = state
            if state in observed:
                new_row[(forecast_date - self.costant.DAY_ZERO).days] = observed[state][forecast_date.strftime("%Y-%m-%d")]
            else:
                new_row[(forecast_date - self.costant.DAY_ZERO).days] = "NaN"
            for date_str in predicted[self.costant.STATES[0]]:
                date = datetime.datetime.strptime(date_str,"%Y-%m-%d")
                if (date.weekday() != 5):
                    continue
                if state in predicted and date_str in predicted[state]:
                    new_row[(date - self.costant.DAY_ZERO).days] = predicted[state][date_str]
                else:
                    new_row[(date - self.costant.DAY_ZERO).days] = "NaN"
            dataframe = dataframe.append(new_row, ignore_index=True)
        output_name = model_name + '_' + str((forecast_date - self.costant.DAY_ZERO).days) + ".csv"
        output_name = output_name.replace('-', '_')
        dataframe.to_csv(self.output_directory + output_name)
        print(output_name + " has been written.")
def write_report ( self , model_name , forecast_date , observed , predicted ) : columns = [ 'State' ] columns . append ( ( forecast_date - self . costant . DAY_ZERO ) . days ) for date_str in predicted [ self . costant . STATES [ 0 ] ] : date = datetime . datetime . strptime ( date_str , "%Y-%m-%d" ) if ( date . weekday ( ) != 5 ) : continue columns . append ( ( datetime . datetime . strptime ( date_str , "%Y-%m-%d" ) - self . costant . DAY_ZERO ) . days ) dataframe = pd . DataFrame ( columns = columns ) for state in self . costant . STATES : new_row = { } new_row [ "State" ] = state if state in observed : new_row [ ( forecast_date - self . costant . DAY_ZERO ) . days ] = observed [ state ] [ forecast_date . strftime ( "%Y-%m-%d" ) ] else : new_row [ ( forecast_date - self . costant . DAY_ZERO ) . days ] = "NaN" for date_str in predicted [ self . costant . STATES [ 0 ] ] : date = datetime . datetime . strptime ( date_str , "%Y-%m-%d" ) if ( date . weekday ( ) != 5 ) : continue if state in predicted and date_str in predicted [ state ] : new_row [ ( date - self . costant . DAY_ZERO ) . days ] = predicted [ state ] [ date_str ] else : new_row [ ( date - self . costant . DAY_ZERO ) . days ] = "NaN" dataframe = dataframe . append ( new_row , ignore_index = True ) output_name = model_name + '_' + str ( ( forecast_date - self . costant . DAY_ZERO ) . days ) + ".csv" output_name = output_name . replace ( '-' , '_' ) dataframe . to_csv ( self . output_directory + output_name ) print ( output_name + " has been written." )
Given a dataset of observed deaths,
a dataset of forecast deaths, the model'sname and a forecast date.
Given a dataset of observed deaths a dataset of forecast deaths the model ' sname and a forecast date .
""" 
        Given a dataset of observed deaths, 
        a dataset of forecast deaths, the model'sname and a forecast date.
        Write down the report into csv form. 
        """ # Skip if the target end day is not Saturday. # Write the first column, observed cumulative deaths on the forecast date.  # Write the incident deaths for the following two weeks. # Skip if the target end day is not Saturday.
self
model_name
forecast_date
observed
predicted