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.31.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.31-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.31.tar.gz.

File metadata

File hashes

Hashes for polars_interval_match-0.1.31.tar.gz
Algorithm Hash digest
SHA256 0354e50d709c72f581b0400edc04401094a19ddb7aa11fa82c87cb201f0d2002
MD5 d8286419b114ddbaa4c64019778aaa47
BLAKE2b-256 a6286356aa8a1184a1cb892b289a2edd72c828957d4c01d833f5e5613966656f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_interval_match-0.1.31-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4e0ade946aa7dd491788337efe975ccbf7b9abdc34a9e5c306db4db302d9d758
MD5 de3801ab988ec481f5e7d791074239fb
BLAKE2b-256 2926cef8087c04297732f9daa17952677fdb41a8d5ce68482ec38f8cb3469b57

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