Пример #1
0
 def get_data(
     self,
     aggregation_level,
     country=None,
     fips: Optional[str] = None,
     state: Optional[str] = None,
     states: Optional[List[str]] = None,
     on: Optional[str] = None,
     after: Optional[str] = None,
     before: Optional[str] = None,
     columns_slice: Optional[List[str]] = None,
 ) -> pd.DataFrame:
     rows_binary_array = dataset_utils.make_binary_array(
         self.data,
         aggregation_level=aggregation_level,
         country=country,
         fips=fips,
         state=state,
         states=states,
         on=on,
         after=after,
         before=before,
     )
     if columns_slice is None:
         columns_slice = slice(None, None, None)
     return self.data.loc[rows_binary_array, columns_slice]
Пример #2
0
    def get_subset(
        self,
        aggregation_level,
        country=None,
        fips: Optional[str] = None,
        state: Optional[str] = None,
        states: Optional[List[str]] = None,
        on: Optional[str] = None,
        after: Optional[str] = None,
        before: Optional[str] = None,
    ) -> "TimeseriesDataset":
        """Fetch a new TimeseriesDataset with a subset of the data in `self`.

        Some parameters are only used in ipython notebooks."""
        row_binary_array = dataset_utils.make_binary_array(
            self.data,
            aggregation_level=aggregation_level,
            country=country,
            fips=fips,
            state=state,
            states=states,
            on=on,
            after=after,
            before=before,
        )
        return self.__class__(self.data.loc[row_binary_array, :])
def column_as_set(
    df: pd.DataFrame,
    column: str,
    aggregation_level,
    state=None,
    states=None,
    on=None,
    after=None,
    before=None,
):
    """Return values in selected rows and column of df.

    Exists to call `make_binary_array` without listing all the parameters.
    """
    rows_binary_array = dataset_utils.make_binary_array(
        df,
        aggregation_level,
        country=None,
        fips=None,
        state=state,
        states=states,
        on=on,
        after=after,
        before=before,
    )
    return set(df.loc[rows_binary_array][column])
Пример #4
0
 def get_subset(
     self,
     aggregation_level=None,
     country=None,
     fips: Optional[str] = None,
     state: Optional[str] = None,
     states: Optional[List[str]] = None,
     on: Optional[str] = None,
     after: Optional[str] = None,
     before: Optional[str] = None,
 ) -> "LatestValuesDataset":
     rows_binary_array = make_binary_array(
         self.data,
         aggregation_level=aggregation_level,
         country=country,
         fips=fips,
         state=state,
         states=states,
         on=on,
         after=after,
         before=before,
     )
     return self.__class__(self.data.loc[rows_binary_array, :])