Skip to main content

A Python extension module for matching intervals in Polars DataFrames

Project description

Polars Interval Match

This package enables the matching of a Polars Series of numerical values (currently only Float64 is supported) to a Series of interval strings (using standard interval notation).

Installation

You can install the package using pip:

pip install polars-interval-match

Usage

Here is a basic example of how to use the match_intervals function:

import polars as pl
from polars_interval_match import match_intervals

# Create a Polars Series of values
values = pl.Series("values", [1.5, 2.5, 3.5, 4.5])

# Create a Polars Series of interval strings
intervals = pl.Series("intervals", ["[1.0, 2.0]", "(2.0, 3.0]", "[3.0, 4.0)", "(4.0, 5.0]"])

# Match values to intervals
matched = match_intervals(values, intervals)

# Show the result
print(matched)

The match_intervals function matches each value in the values Series to the corresponding interval in the intervals Series. The intervals are specified using standard interval notation:

  • [a, b] denotes an interval that includes both endpoints a and b (is closed on both the left and the right).
  • (a, b] denotes an interval that excludes the start point a but includes the endpoint b (is closed on the right only).
  • [a, b) denotes an interval that includes the start point a but excludes the endpoint b (is closed on the left only).
  • (a, b) denotes an interval that excludes both endpoints a and b (is open on both the left and the right).

The function returns a new Polars Series where each value is replaced by the interval it matches.

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

polars_interval_match-0.1.2.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polars_interval_match-0.1.2-cp311-cp311-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

File details

Details for the file polars_interval_match-0.1.2.tar.gz.

File metadata

File hashes

Hashes for polars_interval_match-0.1.2.tar.gz
Algorithm Hash digest
SHA256 0915ee31248eb02c97c5f6c332a99af04e3f936ce2e7691b4c9c17f8f1f94ed6
MD5 d1cfa8a4a13f2a741c5b3c06a1ccb348
BLAKE2b-256 cb16cbdcf1ad646548eb0e8d909fdeb669a42bbd1e296201054492e7ce361080

See more details on using hashes here.

File details

Details for the file polars_interval_match-0.1.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polars_interval_match-0.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0396088174a859d13812d38fd8c0159e99ebfd39b14359a6ebcaec181c7de2e6
MD5 1bf34a70f68bd7bc2a8687ca2d6896e7
BLAKE2b-256 dba30c2d73fecaa6927038a655340007c7ae1d0af86087c23162e61e61ae7ad3

See more details on using hashes here.

Supported by

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