Пример #1
0
def test_column_names(exemplar_spatial_unit_param, ignore_nulls):
    """Test that column_names property matches head(0) for SubscriberLocations"""
    sl = SubscriberLocations(
        "2016-01-01",
        "2016-01-04",
        spatial_unit=exemplar_spatial_unit_param,
        ignore_nulls=ignore_nulls,
    )
    assert sl.head(0).columns.tolist() == sl.column_names
Пример #2
0
    def __init__(
        self,
        start,
        stop,
        *,
        spatial_unit: AnySpatialUnit = make_spatial_unit("cell"),
        subscriber_identifier="msisdn",
        hours: Optional[Tuple[int, int]] = None,
        subscriber_subset=None,
        tables="all",
        ignore_nulls=True,
    ):

        self.subscriber_locations = SubscriberLocations(
            start=start,
            stop=stop,
            spatial_unit=spatial_unit,
            table=tables,
            hours=hours,
            subscriber_identifier=subscriber_identifier,
            subscriber_subset=subscriber_subset,
            ignore_nulls=ignore_nulls,
        )

        super().__init__()
Пример #3
0
def test_can_get_pcods(get_dataframe):
    """
    SubscriberLocations() can make queries at the p-code level.
    """

    subscriber_pcod = SubscriberLocations(
        "2016-01-01 13:30:30",
        "2016-01-02 16:25:00",
        spatial_unit=make_spatial_unit("polygon",
                                       region_id_column_name="admin3pcod",
                                       geom_table="geography.admin3"),
    )
    df = get_dataframe(subscriber_pcod)
    assert df.admin3pcod[0].startswith("524")
Пример #4
0
    def _flowmachine_query_obj(self):
        """
        Return the underlying flowmachine object.

        Returns
        -------
        Query
        """
        return RedactedTripsODMatrix(trips=TripsODMatrix(
            SubscriberLocations(
                self.start_date,
                self.end_date,
                spatial_unit=self.aggregation_unit,
                table=self.event_types,
                subscriber_subset=self.subscriber_subset,
            )))