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

File metadata

File hashes

Hashes for polars_interval_match-0.1.3.tar.gz
Algorithm Hash digest
SHA256 00a657fa1a9b6b8579af2fe3b7514c75f4715cf38ea9a4e37c6519a55f081cc5
MD5 5f7883697af4851e23f84cb68700fa08
BLAKE2b-256 eb9fe0ebe974f865ecac8400b995228d3f9d6c3e8253ade2cc6c644a5aeceb54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polars_interval_match-0.1.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 edb99e3f67e421f2ac4ba75fe40fcfc27616c78e2702d7412c9913abc82aad28
MD5 82ec6b49c4df760fa129bd248f6cea8f
BLAKE2b-256 e63dcd40eed4096e923dbeab3ee2bf10a9bbb8122927624aa6f3247ebfea94af

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