Giter Club home page Giter Club logo

pymove's Introduction

Use PyMove and go much further


Information

Package Status
License
Python Version
Platforms
Build Status
PyPi version
PyPi Downloads
Conda version
Conda Downloads
Code Quality
Code Coverage

What is PyMove

PyMove is a Python library for processing and visualization of trajectories and other spatial-temporal data.

We will also release wrappers to some useful Java libraries frequently used in the mobility domain.

Read the full documentation on ReadTheDocs


Main Features

PyMove proposes:

  • A familiar and similar syntax to Pandas;

  • Clear documentation;

  • Extensibility, since you can implement your main data structure by manipulating other data structures such as Dask DataFrame, numpy arrays, etc., in addition to adding new modules;

  • Flexibility, as the user can switch between different data structures;

  • Operations for data preprocessing, pattern mining and data visualization.


Creating a Virtual Environment

It is recommended to create a virtual environment to use pymove.

Requirements: Anaconda Python distribution installed and accessible

  1. In the terminal client enter the following where env_name is the name you want to call your environment, and replace x.x with the Python version you wish to use. (To see a list of available python versions first, type conda search "^python$" and press enter.)

    • conda create -n <env_name> python=x.x

    • Press y to proceed. This will install the Python version and all the associated anaconda packaged libraries at path_to_your_anaconda_location/anaconda/envs/env_name

  2. Activate your virtual environment. To activate or switch into your virtual environment, simply type the following where yourenvname is the name you gave to your environment at creation.

    • conda activate <env_name>
  3. Now install the package from either conda, pip or github


Conda instalation

  1. conda install -c conda-forge pymove

Pip installation

  1. pip install pymove

Github installation

  1. Clone this repository

    • git clone https://github.com/InsightLab/PyMove
  2. Switch to folder PyMove

    • cd PyMove
  3. Switch to a new branch

    • git checkout -b developer
  4. Make a pull of branch

    • git pull origin developer
  5. Install pymove in developer mode

    • make dev

For windows users

If you installed from pip or github, you may encounter an error related to shapely due to some dll dependencies. To fix this, run conda install shapely.


Examples

You can see examples of how to use PyMove here


Mapping PyMove methods with the Paradigms of Trajectory Data Mining

ZHENG 2015.

  • 1: Spatial Trajectoriespymove.core

    • MoveDataFrame
    • DiscreteMoveDataFrame
  • 2: Stay Point Detectionpymove.preprocessing.stay_point_detection

    • create_or_update_move_stop_by_dist_time
    • create_or_update_move_and_stop_by_radius
  • 3: Map-Matchingpymove-osmnx

  • 4: Noise Filteringpymove.preprocessing.filters

    • by_bbox
    • by_datetime
    • by_label
    • by_id
    • by_tid
    • clean_consecutive_duplicates
    • clean_gps_jumps_by_distance
    • clean_gps_nearby_points_by_distances
    • clean_gps_nearby_points_by_speed
    • clean_gps_speed_max_radius
    • clean_trajectories_with_few_points
    • clean_trajectories_short_and_few_points
    • clean_id_by_time_max
  • 5: Compressionpymove.preprocessing.compression

    • compress_segment_stop_to_point
  • 6: Segmentationpymove.preprocessing.segmentation

    • bbox_split
    • by_dist_time_speed
    • by_max_dist
    • by_max_time
    • by_max_speed
  • 7: Distance Measurespymove.distances

    • medp
    • medt
    • euclidean_distance_in_meters
    • haversine
  • 8: Query Historical Trajectoriespymove.query.query

    • range_query
    • knn_query
  • 9: Managing Recent Trajectories

  • 10: Privacy Preserving

  • 11: Reducing Uncertainty

  • 12: Moving Together Patterns

  • 13: Clusteringpymove.models.pattern_mining.clustering

    • elbow_method
    • gap_statistics
    • dbscan_clustering
  • 14: Freq. Seq. Patterns

  • 15: Periodic Patterns

  • 16: Trajectory Classification

  • 17: Trajectory Outlier / Anomaly Detectionpymove.semantic.semantic

    • outliers
    • create_or_update_out_of_the_bbox
    • create_or_update_gps_deactivated_signal
    • create_or_update_gps_jump
    • create_or_update_short_trajectory
    • create_or_update_gps_block_signal
    • filter_block_signal_by_repeated_amount_of_points
    • filter_block_signal_by_time
    • filter_longer_time_to_stop_segment_by_id

Cite

The library was originally created during the bachelor's thesis of 2 students from the Federal University of Ceará, so you can cite using both works.

@mastersthesis{arina2019,
	title        = {Uma arquitetura e implementação do módulo de pré-processamento para biblioteca PyMove},
	author       = {Arina De Jesus Amador Monteiro Sanches},
	year         = 2019,
	school       = {Universidade Federal Do Ceará},
	type         = {Bachelor's thesis}
}
@mastersthesis{andreza2019,
	title        = {Uma arquitetura e implementação do módulo de visualização para biblioteca PyMove},
	author       = {Andreza Fernandes De Oliveira},
	year         = 2019,
	school       = {Universidade Federal Do Ceará},
	type         = {Bachelor's thesis}
}

Publications


Useful list of related libraries and links

pymove's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pymove's Issues

Support for pandas >=1.4.0

Is your feature request related to a problem? Please describe.
At the moment, the most recent versions of this package do not support pandas >=1.4.0. This version of pandas has been available since January 2022.

Describe the solution you'd like
I'd like to see this package support more recent versions of pandas.

[docs] filters.clean_gps_nearby_points_by_distances radius lacking unit of measure

Describe the bug
There is no unit on the radius of filters.clean_gps_nearby_points_by_distances

I suppose that it is meters, but it should be explicit.

Current docstring

Removes points from the trajectories when the distance between them and the
point before is smaller than the value set by the user.

Parameters
----------
move_data : dataframe
    The input trajectory data
label_id : str, optional
     Indicates the label of the id column in the user dataframe, by default TRAJ_ID
radius_area : float, optional
    Species the minimum distance a point must have to it"srs previous point
    in order not to be dropped, by default 10
label_dtype : type, optional
    Represents column id type, ,y default np.float64.
inplace : boolean, optional
    if set to true the operation is done in place, the original
    dataframe will be altered and None is returned, be default False

Proposed Docstring

Removes points from the trajectories when the distance in meters between them and the
point before is smaller than the value set by the user.

Parameters
----------
move_data : dataframe
    The input trajectory data
label_id : str, optional
     Indicates the label of the id column in the user dataframe, by default TRAJ_ID
radius_area : float, optional
    Species the minimum distance in meters a point must have to it's previous point
    in order not to be dropped, by default 10
label_dtype : type, optional
    Represents column id type, ,y default np.float64.
inplace : boolean, optional
    if set to true the operation is done in place, the original
    dataframe will be altered and None is returned, be default False

Novas visualizações

  • Plotar os pontos de parada
  • Plotar a grid
  • Visualizar trajetórias de diferentes ids com diferentes cores
  • Visualização dos outliers
  • Visualização das trajetórias próximas a um POI
  • Adaptar plot_traj_id() pro Folium
  • Adicionar opções de tiles
  • Por inicio e fim de uma trajetória

Adicionar novas assinaturas das funções do Pandas

  • Adicionar as assinaturas no MoveDataFrameAbstract
  • Adicionar as assinaturas e impl no PandasMoveDataFrame
  • Adicionar as assinaturas e imp no DaskMoveDataFrame
  • Funções/Assinaturas:
  • set e get: tipo df[LAT] e df[LAT] = 3 *
  • min() -> acesso de coluna
  • max() -> acesso de coluna *
  • unique() -> acesso de coluna
  • values *
  • loc
  • iloc *
  • count()
  • reset_index() *
  • groupby()
  • plot() *
  • drop_duplicates()
  • select_dtypes() *
  • columns
  • sort_values() *
  • astype()
  • set_index() *
  • index
  • shape[] *
  • at[]
  • in *
  • dtype
  • drop() *
  • duplicated()
  • shift() *
  • any()
  • dropna *
  • isin
  • append() *
  • dtype
  • head *
  • nunique()
  • to_csv() *
  • astype()
  • dt * n sei oq é, se é de outra lib

OBS: - bbox_split -> segmentation

Padronização funções.

  • Tirar dúvidas das operações de memória e tempo com Nicksson.
  • Verificar se as colunas com a outro nome dá certo ou ele trava.
  • Padronização dos imports
  • Terminar de documentar as funções
  • Verificar se as funções estão de acordo com PEP 8
  • Revisar documentação das funções => Verificar se estão completas e legíveis.
  • Verificar se realmente todas as funções que chamavam create_update_...
    => generate_...
  • Padronização dos init
  • Limpeza do código
  • Verificar TODOs
  • Ajeitar notebooks em seções e organiza-los em pastas.

Funções base do pandas

Adicionar algumas funções base de um dataframe pandas no MoveDataFrame

  • fillna (útil para preencher valores vazios)
  • sample (útil para testar funções utilizando amostragem)
  • all (verifica se todos os valores no dataframe são verdadeiros)
  • isna (verifica se os valores no dataframe são nulos)
  • join (une colunas de outro dataframe)

Ajustes na documentação de core.grid

São necessários ajustes nos docstrings de algumas funções:

  • _create_virtual_grid =>

    • nao referencia parametro data
    • referencia parâmetro inexistente bbox
  • create_all_polygons_to_all_point_on_grid => documentação com parâmetro inexistente dic_grid

Visualizaçoes

Turn off prints

Is your feature request related to a problem? Please describe.
There is too much printing. I rather have an API that does not print as much. For instance, if I want to use it on another project, I want it to run silently.

I'd recommend setting the verbosity to False by default.

Describe the solution you'd like
To have a way to control the verbosity of the logging. Maybe a global parameter that I toggle, ex: pymove.params.verbose=True/False, which controls the printing.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Ajustes nas funções de core.dataframe

Sugestões de alterações dos locais das funções, parâmetros e padronização de semelhantes

  • generate_day_of_the_week, generate_time_of_day => padronizar os nomes das colunas para caixa baixa ou capitalizados

  • generate_time_of_day => trecho do print está mal formatado

  • generate_datetime_in_format_cyclical => não esta perto de outros geradores de features que usam datetime

  • generate_weekend_features =>

    • não esta perto de outros geradores de features que usam datetime
    • create_day_of_week=True não funciona
    • não retorna dataframe indicando fds se inplace=False
    • executar mais de uma vez levanta erro
      AttributeError: 'DataFrame' object has no attribute 'delete'
  • plot_all_features, plot_trajs, plot_traj_id => padronizar parâmetros e retorno

  • plot_traj_id =>

    IndexError: single positional indexer is out-of-bounds
  • any => não existe all

  • isin => existem dois métodos isin

  • to_csv => não possui parametro index

  • last_operation =>

    • às vezes não exibe a última exibindo {'name': 'dtypes', 'time': 0, 'mem': 0}
    • exibir valores de tempo e memoria de forma mais legível
  • impedir que os métodos que modifiquem as colunas removam as colunas necessárias ao MoveDataFrame => dropna, drop, set_index, astype

  • write_file => não esta perto de to_csv

  • len => não esta perto de shape

  • nomes de colunas com ' e "

Ajustes na documentacao de visualization

  • generate_colors => criar docstring

  • zoom_start => descrição de parâmetro errada em varias funções

  • show_lat_lon_gps => falta parâmetro plot_start_and_end na documentação

  • create_base_map => adicionar tile padrão, organizar de parâmetros da documentação

  • heatmap => organização de parâmetros da documentação

Mapeamento e Adição das novas funções do nicksson

  • Adicionar as novas funções do Nicksson
  • Mapear as funções do Nicksson nas funções antigas (tem umas que ele atualizou o escopo)
  • Atualizar os locais das funções no diagrama
  • db.py (conexão a bancos de dados postgres e mongo)
  • semantic.py (Informações semanticas para os pontos das trajetórias)
  • integration.py (Informações sobre pontos de interesse)
  • maputils.py (Algumas novas visualizações)

Documentação online

Criar arquivos .md dentro da pasta docs, pois fica mais organizado e versátil.
Deve-se criar um arquivo inicial que fará link com os demais arquivos

  • Documentação central/inicial: Visualização geral da biblioteca, alguns usos práticos e comuns, encaminhamento pros links de documentação dos módulos
  • Documentação módulo visualização
  • Documentação módulo pré-processamento
  • Documentação módulo core
  • Documentação módulo utils
  • Documentação módulo models

Operações memória e processamento.

  • Criar duas variáveis no MoveDataFrame: nome_ultima_operacao e tempo_de_operacao;
  • Função last_operation_time : time;
    Retorna o tempo de execução da última função.
  • Função last_operation_name : String;
    Retorna o nome da última operação executada.
  • Função last_operation : Dict;
    Retorna o dicionário contendo o nome e a duração da última operação.
  • Função mem(formato) : bytes ou outros formatos;
    Retorna a quantidade de memória consumida pela operação.

Integrar o vaex ao core do pymove

Prerequisites

For more information, see the CONTRIBUTING guide.

Description

Steps to Reproduce

Expected behavior: <!--- What you expected to happen --->

Actual behavior: <!--- What actually happened --->

Possible solution<!--- If you identified how the issue can be fixed or implemented --->

Versions

You can get this information from executing pymove.__version__

Ajustes nas funções de preprocessing

  • filters:

    • by_bbox -> remover inplace para padronizar com os outros
    • clean_nan_values -> corrigir uso do paramentro subset e inplace
    • adicionar inplace, documentação ->
      • clean_gps_jumps_by_distance
      • clean_gps_nearby_points_by_distances
      • clean_gps_speed_max_radius
      • clean_trajectories_with_few_points
      • clean_trajectories_short_and_few_points_
      • clean_id_by_time_max
    • clean_trajectories_short_and_few_points_ -> nome da função
    • clean_id_by_time_max -> criar feature se não existe
  • stay_point_detection: adicionar inplace

  • segmentation: adicionar constantes para novos labels

    • RuntimeWarning: invalid value encountered in greater filter_ = (move_data.at[idx, X] > max_X_between_adj_points)
      • by_dist_time_speed
      • by_speed
      • by_time
      • by_max_dist
      • by_max_time
      • by_max_speed
  • compression: ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

    • compress_segment_stop_to_point
    • compress_segment_stop_to_point_optimizer

Mudanças no nome dos arquivos e funções.

  • Tirar o to_pandas() e to_dask() e por convert_to(new_type).
  • Renomear o arquivo "filter" em preprocessing para "filters".
  • Retirar funções que já estão definidas nas classes presentes no core nos arquivos espalhados do Pymove. Exemplo: show_traj_info no arquivo traj_utils.
  • Tirar o nome utils das funções que estão presentes no pacote utils. Exemplo: traj_utils -> trajectories; date_utils -> date.
  • Mover a função haversine no arquivo traj_utils para um novo arquivo metrics.
  • As funções que iniciarem com o nome do pacote -> retirar o nome do pacote. Exemplo: filter_duplicates... no arquivo filter -> by_duplicates.
  • Por as classes do core em um único arquivo: dataframe
  • Botar na interface as assinaturas com parâmetros comum entre as duas estruturas já existentes.
  • Deixar interface redonda: deixar todas as funcs na interface (ainda não estão)
  • Tirar operações de memória em funções muito básicas

Classe Grid

Formatar a estrutura atual do arquivo grip.py para classe.

Operações de conversão de tipos.

  • Adicionar o atribute type;
  • Função set_type(new_type, in_memory);
  • new_type() : String. Indica o novo tipo para o MoveDataFrame (verificar se o novo tipo é igual ao tipo atual do objeto, caso seja, não fazer nada)
  • in_memory : Boolean
  • True: Cria em memória e deleta o objeto anterior
  • False: Operação realizada em disco. Converte a estrutura antiga como .csv e relê .csv como o novo tipo.
  • Função get_type(): String. Retorna o tipo da estrutura
  • Função to_dask : DaskMoveDataFrame.
  • Função to_pandas : PandasMoveDataFrame.
  • Função read_csv : externo a estrutura

How to carry around a feature column?

Is your feature request related to a problem? Please describe.
When building the MoveDataFrame, there is no clear way on how to carry around an extra feature column that might be useful. For instance, I am working with bus gps data, but I need to carry the trip_id associated to that bus. However, trip_id is not the traj_id. So, I couldn't figure out how to add this extra info to my MoveDataFrame

Describe the solution you'd like
Maybe something like:

    @staticmethod
    def __new__(
        self,
        data: Union[DataFrame, Dict, List],
        latitude: Optional[Text] = LATITUDE,
        longitude: Optional[Text] = LONGITUDE,
        datetime: Optional[Text] = DATETIME,
        traj_id: Optional[Text] = TRAJ_ID,
        feature_cols: Optional[List[str]] = [],
        type_: Optional[Text] = TYPE_PANDAS,
        n_partitions: Optional[int] = 1,
    ):
        """
        Creates the PyMove dataframe, which must contain latitude, longitude and datetime.

        The dataframe can be a pandas or dask dataframe.

        Parameters
        ----------
        data : DataFrame or PandasMoveDataFrame or dict or list
            Input trajectory data.
        latitude : str, optional
            Represents column name latitude, by default LATITUDE
        longitude : str, optional
            Represents column name longitude, by default LONGITUDE
        datetime : str, optional
            Represents column name datetime, by default DATETIME
        traj_id : str, optional
            Represents column name trajectory id, by default TRAJ_ID
        feature_cols: list, optional
            Extra columns that will be carried by the dataframe, by default []
        type_ : str, optional
            Number of partitions of the dask dataframe, by default TYPE_PANDAS
        n_partitions : Optional[int], optional
            Amount of partitions for dask dataframe, by default 1

        Raises
        ------
        KeyError
            If missing one of lat, lon, datetime columns
        ValueError, ParserError
            If the data types can't be converted.
        """

ImportError: cannot import name 'FilePathOrBuffer' from 'pandas._typing'

Describe the bug
Importing pymove raises ImportError: cannot import name 'FilePathOrBuffer' from 'pandas._typing'

To Reproduce
Steps to reproduce the behavior:

  1. Conda install pymove
  2. Run import pymove
(pymove) PS C:\Users\anita> python
Python 3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:34:17) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pymove
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "H:\miniconda3\envs\pymove\lib\site-packages\pymove\__init__.py", line 13, in <module>
    from .core.pandas import PandasMoveDataFrame
  File "H:\miniconda3\envs\pymove\lib\site-packages\pymove\core\pandas.py", line 47, in <module>
    from pymove.utils.trajectories import shift
  File "H:\miniconda3\envs\pymove\lib\site-packages\pymove\utils\trajectories.py", line 23, in <module>
    from pandas._typing import FilePathOrBuffer
ImportError: cannot import name 'FilePathOrBuffer' from 'pandas._typing' (H:\miniconda3\envs\pymove\lib\site-packages\pandas\_typing.py)

Desktop (please complete the following information):

  • OS: Win10
(pymove) PS C:\Users\anita> conda list
# packages in environment at H:\miniconda3\envs\pymove:
#
# Name                    Version                   Build  Channel
argon2-cffi               21.3.0             pyhd8ed1ab_0    conda-forge
argon2-cffi-bindings      21.2.0          py310he2412df_2    conda-forge
asttokens                 2.0.5              pyhd8ed1ab_0    conda-forge
attrs                     21.4.0             pyhd8ed1ab_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.11.1             pyha770c72_0    conda-forge
bleach                    5.0.0              pyhd8ed1ab_0    conda-forge
bokeh                     2.4.2           py310h5588dad_1    conda-forge
branca                    0.4.2              pyhd8ed1ab_0    conda-forge
brotli                    1.0.9                h8ffe710_7    conda-forge
brotli-bin                1.0.9                h8ffe710_7    conda-forge
brotlipy                  0.7.0           py310he2412df_1004    conda-forge
bzip2                     1.0.8                h8ffe710_4    conda-forge
ca-certificates           2021.10.8            h5b45459_0    conda-forge
certifi                   2021.10.8       py310h5588dad_2    conda-forge
cffi                      1.15.0          py310hcbf9ad4_0    conda-forge
charset-normalizer        2.0.12             pyhd8ed1ab_0    conda-forge
click                     8.1.2           py310h5588dad_0    conda-forge
cloudpickle               2.0.0              pyhd8ed1ab_0    conda-forge
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
convertdate               2.4.0              pyhd8ed1ab_0    conda-forge
cryptography              36.0.2          py310ha857299_1    conda-forge
cycler                    0.11.0             pyhd8ed1ab_0    conda-forge
cytoolz                   0.11.2          py310he2412df_2    conda-forge
dask                      2022.4.1           pyhd8ed1ab_0    conda-forge
dask-core                 2022.4.1           pyhd8ed1ab_0    conda-forge
debugpy                   1.6.0           py310h8a704f9_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
distributed               2022.4.1           pyhd8ed1ab_0    conda-forge
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
executing                 0.8.3              pyhd8ed1ab_0    conda-forge
flit-core                 3.7.1              pyhd8ed1ab_0    conda-forge
folium                    0.12.1.post1       pyhd8ed1ab_1    conda-forge
fonttools                 4.32.0          py310he2412df_0    conda-forge
freetype                  2.10.4               h546665d_1    conda-forge
fsspec                    2022.3.0           pyhd8ed1ab_0    conda-forge
geohash2                  1.1                        py_0    conda-forge
geojson                   2.5.0                      py_0    conda-forge
geos                      3.10.2               h39d44d4_0    conda-forge
heapdict                  1.0.1                      py_0    conda-forge
hijri-converter           2.2.3              pyhd8ed1ab_0    conda-forge
holidays                  0.13               pyhd8ed1ab_0    conda-forge
idna                      3.3                pyhd8ed1ab_0    conda-forge
importlib-metadata        4.11.3          py310h5588dad_1    conda-forge
importlib_resources       5.7.1              pyhd8ed1ab_0    conda-forge
intel-openmp              2022.0.0          h57928b3_3663    conda-forge
ipykernel                 6.13.0          py310hbbfc1a7_0    conda-forge
ipython                   8.2.0           py310h5588dad_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.7.0              pyhd8ed1ab_0    conda-forge
jbig                      2.1               h8d14728_2003    conda-forge
jedi                      0.18.1          py310h5588dad_1    conda-forge
jinja2                    3.1.1              pyhd8ed1ab_0    conda-forge
joblib                    1.1.0              pyhd8ed1ab_0    conda-forge
jpeg                      9e                   h8ffe710_0    conda-forge
jsonschema                4.4.0              pyhd8ed1ab_0    conda-forge
jupyter_client            7.2.2              pyhd8ed1ab_1    conda-forge
jupyter_core              4.9.2           py310h5588dad_0    conda-forge
jupyterlab_pygments       0.2.2              pyhd8ed1ab_0    conda-forge
jupyterlab_widgets        1.1.0              pyhd8ed1ab_0    conda-forge
kiwisolver                1.4.2           py310h476a331_1    conda-forge
korean_lunar_calendar     0.2.1              pyh9f0ad1d_0    conda-forge
lcms2                     2.12                 h2a16943_0    conda-forge
lerc                      3.0                  h0e60522_0    conda-forge
libblas                   3.9.0              14_win64_mkl    conda-forge
libbrotlicommon           1.0.9                h8ffe710_7    conda-forge
libbrotlidec              1.0.9                h8ffe710_7    conda-forge
libbrotlienc              1.0.9                h8ffe710_7    conda-forge
libcblas                  3.9.0              14_win64_mkl    conda-forge
libdeflate                1.10                 h8ffe710_0    conda-forge
libffi                    3.4.2                h8ffe710_5    conda-forge
liblapack                 3.9.0              14_win64_mkl    conda-forge
libpng                    1.6.37               h1d00b33_2    conda-forge
libsodium                 1.0.18               h8d14728_1    conda-forge
libtiff                   4.3.0                hc4061b1_3    conda-forge
libwebp                   1.2.2                h57928b3_0    conda-forge
libwebp-base              1.2.2                h8ffe710_1    conda-forge
libxcb                    1.13              hcd874cb_1004    conda-forge
libzlib                   1.2.11            h8ffe710_1014    conda-forge
locket                    0.2.0                      py_2    conda-forge
lz4                       4.0.0           py310h7b86b54_1    conda-forge
lz4-c                     1.9.3                h8ffe710_1    conda-forge
m2w64-gcc-libgfortran     5.3.0                         6    conda-forge
m2w64-gcc-libs            5.3.0                         7    conda-forge
m2w64-gcc-libs-core       5.3.0                         7    conda-forge
m2w64-gmp                 6.1.0                         2    conda-forge
m2w64-libwinpthread-git   5.0.0.4634.697f757               2    conda-forge
markupsafe                2.1.1           py310he2412df_1    conda-forge
matplotlib-base           3.5.1           py310h79a7439_0    conda-forge
matplotlib-inline         0.1.3              pyhd8ed1ab_0    conda-forge
mistune                   0.8.4           py310he2412df_1005    conda-forge
mkl                       2022.0.0           h0e2418a_796    conda-forge
mplleaflet                0.0.5                      py_4    conda-forge
msgpack-python            1.0.3           py310h476a331_1    conda-forge
msys2-conda-epoch         20160418                      1    conda-forge
munkres                   1.1.4              pyh9f0ad1d_0    conda-forge
nbclient                  0.6.0              pyhd8ed1ab_0    conda-forge
nbconvert                 6.5.0              pyhd8ed1ab_0    conda-forge
nbconvert-core            6.5.0              pyhd8ed1ab_0    conda-forge
nbconvert-pandoc          6.5.0              pyhd8ed1ab_0    conda-forge
nbformat                  5.3.0              pyhd8ed1ab_0    conda-forge
nest-asyncio              1.5.5              pyhd8ed1ab_0    conda-forge
notebook                  6.4.10             pyha770c72_0    conda-forge
numpy                     1.22.3          py310hcae7c84_2    conda-forge
openjpeg                  2.4.0                hb211442_1    conda-forge
openssl                   1.1.1n               h8ffe710_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandas                    1.4.2           py310hf5e1058_1    conda-forge
pandoc                    2.18                 h57928b3_0    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
partd                     1.2.0              pyhd8ed1ab_0    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    9.1.0           py310h767b3fd_2    conda-forge
pip                       22.0.4             pyhd8ed1ab_0    conda-forge
prometheus_client         0.14.1             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.29             pyha770c72_0    conda-forge
psutil                    5.9.0           py310he2412df_1    conda-forge
pthread-stubs             0.4               hcd874cb_1001    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.11.2             pyhd8ed1ab_0    conda-forge
pymeeus                   0.5.10             pyhd8ed1ab_0    conda-forge
pymove                    3.0.0              pyhd8ed1ab_0    conda-forge
pyopenssl                 22.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.8              pyhd8ed1ab_0    conda-forge
pyrsistent                0.18.1          py310he2412df_1    conda-forge
pysocks                   1.7.1           py310h5588dad_5    conda-forge
python                    3.10.4          h9a09f29_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-fastjsonschema     2.15.3             pyhd8ed1ab_0    conda-forge
python_abi                3.10                    2_cp310    conda-forge
pytz                      2022.1             pyhd8ed1ab_0    conda-forge
pywin32                   303             py310he2412df_0    conda-forge
pywinpty                  2.0.5           py310h00ffb61_1    conda-forge
pyyaml                    6.0             py310he2412df_4    conda-forge
pyzmq                     22.3.0          py310h73ada01_2    conda-forge
requests                  2.27.1             pyhd8ed1ab_0    conda-forge
scikit-learn              1.0.2           py310h4dafddf_0    conda-forge
scipy                     1.8.0           py310h33db832_1    conda-forge
send2trash                1.8.0              pyhd8ed1ab_0    conda-forge
setuptools                62.1.0          py310h5588dad_0    conda-forge
shapely                   1.8.0           py310h3578588_6    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sortedcontainers          2.4.0              pyhd8ed1ab_0    conda-forge
soupsieve                 2.3.1              pyhd8ed1ab_0    conda-forge
sqlite                    3.38.2               h8ffe710_0    conda-forge
stack_data                0.2.0              pyhd8ed1ab_0    conda-forge
tbb                       2021.5.0             h2d74725_1    conda-forge
tblib                     1.7.0              pyhd8ed1ab_0    conda-forge
terminado                 0.13.3          py310h5588dad_1    conda-forge
threadpoolctl             3.1.0              pyh8a188c0_0    conda-forge
tinycss2                  1.1.1              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h8ffe710_0    conda-forge
toolz                     0.11.2             pyhd8ed1ab_0    conda-forge
tornado                   6.1             py310he2412df_3    conda-forge
tqdm                      4.64.0             pyhd8ed1ab_0    conda-forge
traitlets                 5.1.1              pyhd8ed1ab_0    conda-forge
typing_extensions         4.2.0              pyha770c72_0    conda-forge
tzdata                    2022a                h191b570_0    conda-forge
ucrt                      10.0.20348.0         h57928b3_0    conda-forge
unicodedata2              14.0.0          py310he2412df_1    conda-forge
urllib3                   1.26.9             pyhd8ed1ab_0    conda-forge
vc                        14.2                 hb210afc_6    conda-forge
vs2015_runtime            14.29.30037          h902a5da_6    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
widgetsnbextension        3.6.0           py310h5588dad_0    conda-forge
win_inet_pton             1.1.0           py310h5588dad_4    conda-forge
winpty                    0.4.3                         4    conda-forge
xorg-libxau               1.0.9                hcd874cb_0    conda-forge
xorg-libxdmcp             1.1.3                hcd874cb_0    conda-forge
xz                        5.2.5                h62dcd97_1    conda-forge
yaml                      0.2.5                h8ffe710_2    conda-forge
zeromq                    4.3.4                h0e60522_1    conda-forge
zict                      2.1.0              pyhd8ed1ab_0    conda-forge
zipp                      3.8.0              pyhd8ed1ab_0    conda-forge
zlib                      1.2.11            h8ffe710_1014    conda-forge
zstd                      1.5.2                h6255e5f_0    conda-forge

Atualizar dependências

Adicionar dask[dataframe] e sklearn as dependências em setyp.py

Ao instalar usando pip ou importar o módulo pela pasta e importar o pymove gera o erro de que as bibliotecas dask[dataframe] e sklearn não foram encontradas

create_or_update_move_stop_by_dist_time - does not create stay point using distance

Describe the bug
The function create_or_update_move_stop_by_dist_time claims to create a stay point based on both time and distance metrics. Because the documentation is sparse, I went looking in the source code for an explanation of how it works. I can clearly see where the data is aggregated and queried by the time to the previous point, but I see no where that the data is queried by the distance. The input dist_radius appears nowhere in the actual function.

To Reproduce
Go to: https://github.com/InsightLab/PyMove/blob/ee5b68282502bfcb9cf38b52dcdefed5bd927a90/pymove/preprocessing/stay_point_detection.py

ctrl+F: dist_radius

Appears only in the doc string of the function. No other distance parameter is apparent.

Ajustes nas funções de visualization

  • save_map => erro ao gerar com mais de 1 id
ValueError: Locations is empty.
  • save_wtk => erro ao gerar arquivo
KeyError: ('lon', 'lat')
  • show_object_id_by_date, show_lat_lon_gps => padronizar com funções de plot de core.dataframe (return_fig, save_fig, ...)

  • plot_trajectories_with_folium => gera mapa com todas as trajetórias como se fosse apenas de 1 usuário. gerar para cada usuário, com cores diferentes

  • plot_trajectory_by_period, plot_trajectory_by_day_week, plot_trajectory_by_date, plot_trajectory_by_hour => tratar erro de requisito não encontrado no dataframe

  • plot_trajectory_by_period, plot_trajectory_by_day_week, plot_trajectory_by_date, plot_trajectory_by_hour, plot_stops => cores diferentes para cada usuário

Funções com inplace

  • generate_tid_based_on_id_datatime

  • generate_date_features

  • generate_hour_features

  • generate_day_of_the_week_features

  • generate_time_of_day_features

  • generate_dist_features

  • generate_dist_time_speed_features

  • generate_move_and_stop_by_radius

  • change_df_feature_values_using_filter

  • change_df_feature_values_using_filter_and_indexes

  • Vê se tem +

Ajustes nas funções de utils

  • conversions:

    • ms_to_kmh
    • kmh_to_ms
    • meters_to_kilometers
    • kilometers_to_meters
    • seconds_to_minutes
    • minute_to_seconds
    • minute_to_hours
    • hours_to_minute
    • seconds_to_hours
    • hours_to_seconds
    • parâmetro inplace
    • corrigir conversões quando a feature não existe
  • datetime:

    • working_day -> TypeError: argument of type 'datetime.datetime' is not iterable
  • math:

    • arrays_avg -> função está dando erro ao rodar
    • avg_std -> ValueError: (size - avg^2) (size=20, avg=30.0, sum_sq=600) should be non negative
    • avg_std_sample -> ValueError: (size - avg^2) (size=5, avg=120.0, sum_sq=20) should be non negative
  • trajectories:

    • format_labels: ajustar parâmetros
    • Completar as infos ->
      • log_progress
    • fill_list_with_new_values: erro se tentar converter int para str e funcao n verifica isso

Folium throwing a bunch of errors

Hi,

I'm just trying out PyMove because it seems like it could bring a lot to my current project.
But I can't get any folium functionality to work, though.

Here's an extract of what I'm doing:

df.head()
absolute_time lat lng id
2021-09-09 10:32:27.000 45.818459 3.139887 54
2021-09-09 10:32:28.000 45.818459 3.139887 54
2021-09-09 10:32:29.044 45.818459 3.139887 54
2021-09-09 10:32:30.000 45.818459 3.139887 54
2021-09-09 10:32:31.000 45.818459 3.139887 54
move_df = MoveDataFrame(data=df, latitude='lat', longitude='lng', datetime='absolute_time')

from pymove import folium as f
f.plot_trajectories(move_df)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-159-487305dba7d4> in <module>()
      1 from pymove import folium as f
----> 2 f.plot_trajectories(move_df)

2 frames
/usr/local/lib/python3.7/dist-packages/pymove/visualization/folium.py in plot_trajectories(move_data, n_rows, lat_origin, lon_origin, zoom_start, legend, base_map, tile, save_as_html, color, color_by_id, filename)
    993 
    994     _add_trajectories_to_map(
--> 995         mv_df, items, base_map, legend, save_as_html, filename
    996     )
    997 

/usr/local/lib/python3.7/dist-packages/pymove/visualization/folium.py in _add_trajectories_to_map(move_data, items, base_map, legend, save_as_html, filename)
    896         mv = move_data[move_data[TRAJ_ID] == _id]
    897 
--> 898         _add_begin_end_markers_to_map(mv, base_map, color, _id)
    899 
    900         folium.PolyLine(

/usr/local/lib/python3.7/dist-packages/pymove/visualization/folium.py in _add_begin_end_markers_to_map(move_data, base_map, color, _id)
    837         popup='Início',
    838         icon=plugins.BeautifyIcon(
--> 839             icon='play', icon_shape='marker', background_color=color or 'green'
    840         )
    841     ).add_to(points)

TypeError: __init__() got an unexpected keyword argument 'color'

Or if I just try to plot the bounding box, I get a different error.

f.plot_bbox(move_df.get_bbox(), color='blue')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-161-03377951b622> in <module>()
----> 1 f.plot_bbox(move_df.get_bbox(), color='blue')

6 frames
/usr/local/lib/python3.7/dist-packages/pymove/visualization/folium.py in plot_bbox(bbox_tuple, base_map, tiles, color, save_as_html, filename)
   1688         base_map = folium.Map(tiles=tiles)
   1689     base_map.fit_bounds(
-> 1690         [[bbox_tuple[0], bbox_tuple[1]], [bbox_tuple[2], bbox_tuple[3]]]
   1691     )
   1692     points_ = [

/usr/local/lib/python3.7/dist-packages/folium/folium.py in fit_bounds(self, bounds, padding_top_left, padding_bottom_right, padding, max_zoom)
    411             'Choropleth class, which has the same arguments. See the example '
    412             'notebook \'GeoJSON_and_choropleth\' for how to do this.',
--> 413             FutureWarning
    414         )
    415         from folium.features import Choropleth

/usr/local/lib/python3.7/dist-packages/folium/map.py in __init__(self, bounds, padding_top_left, padding_bottom_right, padding, max_zoom)
    456         Bounding box specified as two points [southwest, northeast]
    457     padding_top_left: (x, y) point, default None
--> 458         Padding in the top left corner. Useful if some elements in
    459         the corner, such as controls, might obscure objects you're zooming
    460         to.

/usr/lib/python3.7/json/__init__.py in dumps(obj, skipkeys, ensure_ascii, check_circular, allow_nan, cls, indent, separators, default, sort_keys, **kw)
    229         cls is None and indent is None and separators is None and
    230         default is None and not sort_keys and not kw):
--> 231         return _default_encoder.encode(obj)
    232     if cls is None:
    233         cls = JSONEncoder

/usr/lib/python3.7/json/encoder.py in encode(self, o)
    197         # exceptions aren't as detailed.  The list call should be roughly
    198         # equivalent to the PySequence_Fast that ''.join() would do.
--> 199         chunks = self.iterencode(o, _one_shot=True)
    200         if not isinstance(chunks, (list, tuple)):
    201             chunks = list(chunks)

/usr/lib/python3.7/json/encoder.py in iterencode(self, o, _one_shot)
    255                 self.key_separator, self.item_separator, self.sort_keys,
    256                 self.skipkeys, _one_shot)
--> 257         return _iterencode(o, 0)
    258 
    259 def _make_iterencode(markers, _default, _encoder, _indent, _floatstr,

/usr/lib/python3.7/json/encoder.py in default(self, o)
    177 
    178         """
--> 179         raise TypeError(f'Object of type {o.__class__.__name__} '
    180                         f'is not JSON serializable')
    181 

TypeError: Object of type float16 is not JSON serializable

I'm using python version 3.7, PyMove version 3.0.0, and folium version 0.8.3

Encurtamento de acesso a funcionalidades

  • Definir no init.py do root do pymove links para as principais funcionalidades da ferramenta, a fim de que o acesso aos métodos não seja tão extenso.
    • PandasMoveDataFrame
    • DaskMoveDataFrame
    • ver outros

Script pra atualizar versão PyMove no pip

Function inplace by default

Describe the bug
Some functions have inplace=True by default, confusing user.

To Reproduce
Steps to reproduce the behavior:

  1. df = pm.read_csv('data.csv')
  2. df_stops = pm.preprocessing.stay_point_detection.create_or_update_move_stop_by_dist_time(df)
  3. df_compressed = pm.preprocessing.compression.compress_segment_stop_to_point(df_stops)
  4. See error: TypeError: 'NoneType' object is not subscriptable

Expected behavior
create_or_update_move_stop_by_dist_time returns a new dataframe by default

Screenshots
photo5118680794775267494

Units - no units on stay points inputs; is it possible to use arbitrary x,y units

Discussed in #213

Originally posted by ddileonardo March 11, 2022
Hello,

I am investigating pymove for use in a project I am working on. Specifically I need to find stay points. I have questions about the units that I can use with pymove.

MoveDataFrame: The function inputs specify latitude and longitude. But could I use an arbitrary coordinate system. For example could I use UTM northing and easting instead? Or really any arbitrary x and y coordinate system?

stay_point_detection.create_or_update_move_stop_by_dist_time: the function does not specify the units of time and distance that should be used.
What is the unit of time that you are using?
Should the units for distance match whatever the coordinate system unit is? Is the unit of distance degrees to match a lat/lon coordinate system or something else? The example from the documentation just says 40, but 40 degrees doesn't seem to make sense as a distance value.

I couldn't find any documentation about the appropriate units.

Thanks.

Ajustes na documentação de core.dataframe

São necessários ajustes nos docstrings de algumas funções:

  • _has_columns => erro na tradução (whether past data)

  • _validate_move_data_frame => erro na tradução (default PyMove lib used)

  • generate_tid_based_on_id_datatime => documentação possui trecho não condizente com a função

  • generate_date_features, generate_hour_features => não especifica que extrai as features da coluna datetime

  • generate_dist_features => erro gramatical (three distance in meters to an GPS)

  • generate_dist_time_speed_features =>

    • (create two feature to time between two P)
    • comentário para data_[DIST_TO_PREV] = label_dtype(-1.0) errado ("""create new feature to time""")
    • comentário maiúsculo ("""set Speed features""")
  • show_trajectories_info => documentação descreve parâmetro não existente

  • min => repetição na documentação (Returns and returns the minimum)

  • sort => na documentacao da a entender que indica que o dataframe passado esta ordenado, nao que sera ordenado

Erro nas funções append, join

  • Erro ao acrescentar dataframe do tipo PandasMoveDataFrame. Não acontece se o objeto for do tipo pandas.core.frame.DataFrame
 AttributeError: 'DataFrame' object has no attribute 'blocks'
  • Erro ao unir dataframe do tipo PandasMoveDataFrame. Não acontece se o objeto for do tipo pandas.core.frame.DataFrame
 TypeError: Input must be Index or array-like

Ajustes nas funções de core.grid

Sugestões de alterações nas funções, parâmetros e padronização de semelhantes

  • show_grid_polygons =>

    • dataframe precisa conter polygons. criar caso não exista?
    • padronizar com funções de plot de core.dataframe
  • tqdm => não exibe barra de progresso

  • last_operation => adicionar?

Bugs

  • Ajeitar o negocio do resources que tá comentado (solução aqui https://stackoverflow.com/questions/938733/total-memory-used-by-python-process)
  • Revisar docs das funções
  • Botar pra sempre retornar um objeto do tipo MoveDataFrame -> O que tá acontecendo: tenho um move dataframe, quando ponho uma operação .loc, .iloc, at ele retorna um dataframe
  • Melhorar exibição de legendas no folium
  • Validar colunas ao gerar dataframe.
>>> list_data = [
             [39.984094, 116.319236, '2008-10-23 05:53:05', 1],
             [39.984198, 116.319322, '2008-10-23 05:53:06', 1],
             [39.984224, 116.319402, '2008-10-23 05:53:11', 1],
             [39.984224, 116.319402, '2008-10-23 05:53:11', 1],
             [39.984224, 116.319402, '2008-10-23 05:53:11', 1],
             [39.984224, 116.319402, '2008-10-23 05:53:11', 1]
]
>>> move_df = pymove.PandasMoveDataFrame(data=list_data, latitude="lat", longitude="lon", datetime="datetime", traj_id="id")
>>> print(move_df.dtypes)
lat         float64
lon         float64
datetime     object
id            int64
dtype: object
  • Tratar caso de dataframe sem as colunas do tipo especificado em plot_all_features
  • Exibir versão correta do pymove instalado através do pip
>>> import pymove
>>> pymove.__version__
'0+unknown'
  • Corrigir erro ao ler dataframe usando pm.read_csv com coluna de data com nome não padrão
df = pd.read_csv(filename, sep=sep, encoding=encoding, parse_dates=["datetime"])
  • Permitir a leitura de arquivos sem header utilizando pymove.read_csv(filename)
  • Erro ao instalar no windows devido ao README.md
    “path_to_your_anaconda_location/anaconda/envs/yourenvname”
  • Erro ao importar o pymove no windows devido aos módulos pwd e resource
  • Rever funções em pymove.utils.datetime
    • slot_of_day_to_time
    • slot_of_day
    • slot
    • str_to_min_slot
  • Ao plotar multiplas trajetória no foliim, é exibido apenas um marcador de início e fim
  • Modificar os marcadores de início e fim de trajetória para ficarem mais legíveis

Muito bom o pacote!

Caros,

estou trabalhando na Secretaria Municipal de Transportes do Rio de Janeiro e estamos com alguns projetos que usarão dados de GPS.

Nós gostaríamos de usar o PyMove, ainda mais agora que sei que os devs são brasileiros. Vamos marcar uma conversa? Assim entendo melhor do projeto e vocês podem ver quais features podem ser interessantes para nós.

O que acham? só mandar um email para [email protected]

Operações do DaskMoveDataFrame.

  • get_users_number(self)
  • write_file(self, file_name, separator = ',')
  • get_bbox(self)
  • generate_date_features(self)
  • generate_hour_features(self)
  • generate_day_of_the_week_features(self)
  • generate_time_of_day_features(self)
  • generate_dist_features(self, label_id=TRAJ_ID, label_dtype=np.float64, sort=True)
  • generate_dist_time_speed_features(self, label_id=TRAJ_ID, label_dtype=np.float64, sort=True)
  • generate_move_and_stop_by_radius(self, radius=0, target_label=DIST_TO_PREV)
  • time_interval(self)
  • plot_all_features(self, figsize=(21, 15), dtype=np.float64, save_fig=True, name='features.png')
  • show_trajectories_info(self)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.