Skip to main content

No project description provided

Project description

Tabular data processing for Continuous REPresentation

pytest

pip install crep

This simple module aims at providing some function to tackle tabular data that have a continuous axis. In situations, this index can represent time, but this tool was originally developed to tackle rail way description.

This simple tools helps providing tools to represent a linear structure (cable, rail, beam, pipe) whose characteristics are piece-wize constant (of strongly heterogeneous length)

Basic usage

  • Merge function merge together two dataframe
import pandas as pd

from crep import merge


df_left = pd.DataFrame(
    dict(id=[2, 2, 2],
         t1=[0, 100, 120],
         t2=[100, 120, 130],
         data1=[0.2, 0.1, 0.5])
)
df_right = pd.DataFrame(
    dict(id=[2, 2, 2],
         t1=[0, 80, 100],
         t2=[70, 100, 140],
         data2=[0.1, 0.3, 0.2])
)

ret = merge(data_left=df_left,
            data_right=df_right,
            id_continuous=["t1", "t2"],
            id_discrete=["id"],
            how="outer")

Yield the following result

drawing

Tools

Test if your data is admissible to the merge function, you can use the tools module

import pandas as pd

from crep import tools


df_admissible = pd.DataFrame(
    dict(id=[2, 2, 2],
         t1=[0, 100, 120],
         t2=[100, 120, 130],
         data1=[0.2, 0.1, 0.5])
)
df_not_admissible = pd.DataFrame(
    dict(id=[2, 2, 2],
         t1=[0, 90, 120],
         t2=[100, 120, 130],
         data1=[0.2, 0.1, 0.5])
)
# the second table is not admissible because for t in [90,100] two values are possible

assert tools.admissible_dataframe(
    df_admissible, id_continuous=["t1", "t2"],
    id_discrete=["id"])
assert not tools.admissible_dataframe(
    df_not_admissible, id_continuous=["t1", "t2"],
    id_discrete=["id"])
print(tools.sample_non_admissible_data(
    df_not_admissible, id_continuous=["t1", "t2"],
    id_discrete=["id"]
))
# id  t1   t2  data1
# 1   2  90  120    0.1

Acknowledgement

This implementation come from an SNCF DTIPG project and is developed and maintained by Mews Labs and SNCF DTIPG.

drawing drawing

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

crep-2024.2.5.tar.gz (18.3 kB view details)

Uploaded Source

Built Distribution

crep-2024.2.5-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

Details for the file crep-2024.2.5.tar.gz.

File metadata

  • Download URL: crep-2024.2.5.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for crep-2024.2.5.tar.gz
Algorithm Hash digest
SHA256 59c83e1a11d1a2d0638d78c51f1d08ee7749e967ac135864a87cad1bd9b7ac24
MD5 95e3e21ef6151dd569ff6f28a4419d72
BLAKE2b-256 b61d1f1698328a455bed50269319cf4d901f52a70a44bef280b258476734312c

See more details on using hashes here.

File details

Details for the file crep-2024.2.5-py3-none-any.whl.

File metadata

  • Download URL: crep-2024.2.5-py3-none-any.whl
  • Upload date:
  • Size: 17.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for crep-2024.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 2264e9c965d089c00e200fefffb22c5d72b0dca0ee1c1022cd2c6ec77991c7d7
MD5 000f823d2ea8106815d3e3e7ca13ce47
BLAKE2b-256 00a3deee2251e23c5e378aff1e0e39bcdcdff810b139f2545c415e784a9ceb0d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page