pymove.query package¶
Submodules¶
pymove.query.query module¶
Query operations.
range_query, knn_query
-
pymove.query.query.
knn_query
(traj: pandas.core.frame.DataFrame, move_df: pandas.core.frame.DataFrame, k: int = 5, id_: str = 'id', distance: str = 'MEDP', latitude: str = 'lat', longitude: str = 'lon', datetime: str = 'datetime') → pandas.core.frame.DataFrame[source]¶ Returns the k neighboring trajectories closest to the trajectory.
Given a k, a trajectory and a DataFrame with multiple paths.
Parameters: - traj (dataframe) – The input of one trajectory.
- move_df (dataframe) – The input trajectory data.
- k (int, optional) – neighboring trajectories, by default 5
- id (str, optional) – Label of the trajectories dataframe user id, by default TRAJ_ID
- distance (string, optional) – Distance measure type, by default MEDP
- latitude (string, optional) – Label of the trajectories dataframe referring to the latitude, by default LATITUDE
- longitude (string, optional) – Label of the trajectories dataframe referring to the longitude, by default LONGITUDE
- datetime (string, optional) – Label of the trajectories dataframe referring to the timestamp, by default DATETIME
Returns: dataframe with near trajectories
Return type: DataFrame
Raises: ValueError: if distance measure is invalid
-
pymove.query.query.
range_query
(traj: pandas.core.frame.DataFrame, move_df: pandas.core.frame.DataFrame, _id: str = 'id', min_dist: float = 1000, distance: str = 'MEDP', latitude: str = 'lat', longitude: str = 'lon', datetime: str = 'datetime') → pandas.core.frame.DataFrame[source]¶ Returns all trajectories that have a distance equal to or less than the trajectory.
Given a distance, a trajectory, and a DataFrame with several trajectories.
Parameters: - traj (dataframe) – The input of one trajectory.
- move_df (dataframe) – The input trajectory data.
- _id (str, optional) – Label of the trajectories dataframe user id, by default TRAJ_ID
- min_dist (float, optional) – Minimum distance measure, by default 1000
- distance (string, optional) – Distance measure type, by default MEDP
- latitude (string, optional) – Label of the trajectories dataframe referring to the latitude, by default LATITUDE
- longitude (string, optional) – Label of the trajectories dataframe referring to the longitude, by default LONGITUDE
- datetime (string, optional) – Label of the trajectories dataframe referring to the timestamp, by default DATETIME
Returns: dataframe with near trajectories
Return type: DataFrame
Raises: ValueError: if distance measure is invalid