flowmachine.features.subscriber.distance_series¶
Source: flowmachine/features/subscriber/distance_series.py
Per subscriber time series of distances from some reference location.
Class DistanceSeries¶
DistanceSeries(*, subscriber_locations: flowmachine.features.utilities.subscriber_locations.SubscriberLocations, reference_location: Union[flowmachine.features.utilities.subscriber_locations.BaseLocation, Tuple[float, float]] = (0, 0), statistic: flowmachine.core.statistic_types.Statistic = <Statistic.AVG: 'avg'>, time_bucket: str = 'day')
Per subscriber time series of distance in meters from some reference location. For the time series, returns the first date/datetime within the time bucket for each row, e.g. 1/1/1999 for a year bucket, 1/1/2026, ½/2026 and so on for a month bucket.
Attributes¶
Parameters¶
-
subscriber_locations
:flowmachine.features.utilities.subscriber_locations.SubscriberLocations
A subscriber locations query with a lon-lat spatial unit to build the distance series against.
-
reference_location
:typing.Union
, default(0, 0)
The set of home locations from which to calculate distance at each sighting, or a tuple of lon-lat in WS84 projection.
-
statistic
:flowmachine.core.statistic_types.Statistic
, defaultavg
the statistic to calculate.
-
time_bucket
:str
, defaultday
Time bucket to calculate the statistic over.
Examples¶
d = DistanceSeries(subscriber_locations=SubscriberLocations("2016-01-01", "2016-01-07", spatial_unit=make_spatial_unit("lon-lat")))
d.head()
subscriber datetime value
0 038OVABN11Ak4W5P 2016-01-01 9.384215e+06
1 038OVABN11Ak4W5P 2016-01-02 9.233302e+06
2 038OVABN11Ak4W5P 2016-01-03 9.376996e+06
3 038OVABN11Ak4W5P 2016-01-04 9.401404e+06
4 038OVABN11Ak4W5P 2016-01-05 9.357210e+06
Note
The datetime column will contain dates for time buckets longer than an hour, and datetimes for time buckets less than a day.
Methods¶
cache¶
cache
Returns¶
-
bool
True is caching is switched on.
column_names¶
column_names
Returns the column names.
Returns¶
-
typing.List
List of the column names of this query.
column_names_as_string_list¶
column_names_as_string_list
Get the column names as a comma separated list
Returns¶
-
str
Comma separated list of column names
dependencies¶
dependencies
Returns¶
-
set
The set of queries which this one is directly dependent on.
fully_qualified_table_name¶
fully_qualified_table_name
Returns a unique fully qualified name for the query to be stored as under the cache schema, based on a hash of the parameters, class, and subqueries.
Returns¶
-
str
String form of the table's fqn
index_cols¶
index_cols
A list of columns to use as indexes when storing this query.
Returns¶
-
ixen
:list
By default, returns the location columns if they are present and self.spatial_unit is defined, and the subscriber column.
Examples¶
daily_location("2016-01-01").index_cols
[['name'], '"subscriber"']
is_stored¶
is_stored
Returns¶
-
bool
True if the table is stored, and False otherwise.
query_id¶
query_id
Generate a uniquely identifying hash of this query, based on the parameters of it and the subqueries it is composed of.
Returns¶
-
str
query_id hash string
query_state¶
query_state
Return the current query state.
Returns¶
-
QueryState
The current query state
query_state_str¶
query_state_str
Return the current query state as a string
Returns¶
-
str
The current query state. The possible values are the ones defined in
flowmachine.core.query_state.QueryState
.
table_name¶
table_name
Returns a uniquename for the query to be stored as, based on a hash of the parameters, class, and subqueries.
Returns¶
-
str
String form of the table's fqn