Exemplo n.º 1
0
    def parse_dataframes(
        self, dataframes: Dict[str, DataFrame], aux: Dict[str, DataFrame], **parse_opts
    ) -> DataFrame:

        data = dataframes[0]

        data["date"] = data.REPORT_DATE.apply(lambda x: datetime_isoformat(x, "%Y-%m-%d"))
        # Add level1 keys
        subregion1s = country_subregion1s(aux["metadata"], "AU")
        data = table_merge([data, subregion1s], left_on="CODE", right_on="subregion1_code", how="left")
        # Country-level record has CODE AUS
        country_mask = data["CODE"] == "AUS"
        data.loc[country_mask, "key"] = "AU"
        # Only keep country and subregion1 rows
        data = data[data.key != None]
        data = table_rename(
            data,
            {
                "date": "date",
                "key": "key",
                "VACC_DOSE_CNT": "total_vaccine_doses_administered",
                "VACC_PEOPLE_CNT": "total_persons_fully_vaccinated",
            },
            drop=True)
        # remove rows without vaccination data
        data.dropna(subset=["total_vaccine_doses_administered", "total_persons_fully_vaccinated"], how="all", inplace=True)
        # based on the assumption two doses = fully vaccinated(since Australia is using Pfizer and AZ)
        data["total_persons_vaccinated"] = estimate_total_persons_vaccinated(data)

        return data
Exemplo n.º 2
0
 def parse(self, sources: Dict[str, str], aux: Dict[str, DataFrame], **parse_opts) -> DataFrame:
     subregion1s = country_subregion1s(aux["metadata"], "ID")
     subregion2s = country_subregion2s(aux["metadata"], "ID")
     data = concat([
         _get_data(sources['subregion1_url'], 'subregion1_code', _subregion1_code_to_api_id_map, subregion1s),
         _get_data(sources['subregion2_url'], 'subregion2_code', _subregion2_code_to_api_id_map, subregion2s),
     ])
     return data
Exemplo n.º 3
0
    def parse_dataframes(self, dataframes: Dict[str, DataFrame],
                         aux: Dict[str, DataFrame], **parse_opts) -> DataFrame:

        data = table_rename(dataframes[0], _column_adapter, drop=True)
        data.date = data.date.apply(
            lambda x: datetime_isoformat(x, "%d/%m/%Y"))
        # add location keys
        subregion1s = country_subregion1s(aux["metadata"], "IN")
        data = table_merge([data, subregion1s[["key", "subregion1_name"]]],
                           on=["subregion1_name"],
                           how="inner")
        return data
    def parse_dataframes(self, dataframes: Dict[str, DataFrame],
                         aux: Dict[str, DataFrame], **parse_opts) -> DataFrame:

        data = dataframes[0]
        # Flatten the table
        data = melt(data,
                    id_vars=["State"],
                    var_name="date",
                    value_name='total_vaccine_doses_administered')
        data.date = data.date.apply(
            lambda x: datetime_isoformat(x, "%d/%m/%Y"))
        # add location keys
        subregion1s = country_subregion1s(aux["metadata"], "IN")
        data = table_merge([data, subregion1s[['key', 'subregion1_name']]],
                           left_on="State",
                           right_on='subregion1_name',
                           how="inner")
        return data