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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polars_interval_match-0.1.21.tar.gz.
File metadata
- Download URL: polars_interval_match-0.1.21.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7dd711431b2b54e3fa4a526718ca73b25c6f44de33b0bcca84c4f759a22568e
|
|
| MD5 |
fd25590c22a447c0505e70002a236f35
|
|
| BLAKE2b-256 |
ebcc90cdddc1c15a2bf6cdb5dc9fcd48274e4ab96ced17e91b841632790c14dd
|
File details
Details for the file polars_interval_match-0.1.21-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: polars_interval_match-0.1.21-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.4 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b229a2d31f17a8fae16e3a33081f472f626a8ff3479c8c4d0f9158c6dc34e737
|
|
| MD5 |
e7dfdeb6e18f79c7022f8b03c639b523
|
|
| BLAKE2b-256 |
d0dfab1bbd741af79d5e69b1d1490142852c2ee0a17dae9dca53af165c40d3cf
|