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.30.tar.gz (26.7 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.30-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.30.tar.gz.

File metadata

File hashes

Hashes for polars_interval_match-0.1.30.tar.gz
Algorithm Hash digest
SHA256 fadb475090159edafbbf8337853c89186cfb838468d2cbca0d82819825959fd3
MD5 037273d16afd3829e55248563a191036
BLAKE2b-256 cb6252f421d12899133d470a6422057fc3dc8bdd055d53fb706e4c4f29f2a288

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_interval_match-0.1.30-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bd6e62ede1acaf24894495d210eb5873853fd1716a53942de13741b535749b4f
MD5 32fb081c6be06ead3c27d6dd15550175
BLAKE2b-256 a02de935880d54031d2c83900269f5dfa1ede619fc3b4e0e80deca2b79f567de

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