# 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:
```sh
pip install polars-interval-match
```
## Usage
Here is a basic example of how to use the `match_intervals` function:
```python
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.
Raw data
{
"_id": null,
"home_page": null,
"name": "polars-interval-match",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": "Kyle Slugg-Urbino <kyle.slugg@gmail.com>",
"keywords": "Polars, interval, data science, data wrangling, plugin",
"author": null,
"author_email": "Kyle Slugg-Urbino <kyle.slugg@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/a6/28/6356aa8a1184a1cb892b289a2edd72c828957d4c01d833f5e5613966656f/polars_interval_match-0.1.31.tar.gz",
"platform": null,
"description": "# Polars Interval Match\n\nThis 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).\n\n## Installation\n\nYou can install the package using pip:\n\n```sh\npip install polars-interval-match\n```\n\n## Usage\n\nHere is a basic example of how to use the `match_intervals` function:\n\n```python\nimport polars as pl\nfrom polars_interval_match import match_intervals\n\n# Create a Polars Series of values\nvalues = pl.Series(\"values\", [1.5, 2.5, 3.5, 4.5])\n\n# Create a Polars Series of interval strings\nintervals = pl.Series(\"intervals\", [\"[1.0, 2.0]\", \"(2.0, 3.0]\", \"[3.0, 4.0)\", \"(4.0, 5.0]\"])\n\n# Match values to intervals\nmatched = match_intervals(values, intervals)\n\n# Show the result\nprint(matched)\n```\n\nThe 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:\n\n- `[a, b]` denotes an interval that includes both endpoints a and b (is closed on both the left and the right).\n- `(a, b]` denotes an interval that excludes the start point a but includes the endpoint b (is closed on the right only).\n- `[a, b)` denotes an interval that includes the start point a but excludes the endpoint b (is closed on the left only).\n- `(a, b)` denotes an interval that excludes both endpoints a and b (is open on both the left and the right).\n\nThe function returns a new Polars `Series` where each value is replaced by the interval it matches.\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python extension module for matching intervals in Polars DataFrames",
"version": "0.1.31",
"project_urls": null,
"split_keywords": [
"polars",
" interval",
" data science",
" data wrangling",
" plugin"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "2926cef8087c04297732f9daa17952677fdb41a8d5ce68482ec38f8cb3469b57",
"md5": "de3801ab988ec481f5e7d791074239fb",
"sha256": "4e0ade946aa7dd491788337efe975ccbf7b9abdc34a9e5c306db4db302d9d758"
},
"downloads": -1,
"filename": "polars_interval_match-0.1.31-cp311-cp311-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "de3801ab988ec481f5e7d791074239fb",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.10",
"size": 3420875,
"upload_time": "2024-11-26T20:05:50",
"upload_time_iso_8601": "2024-11-26T20:05:50.681977Z",
"url": "https://files.pythonhosted.org/packages/29/26/cef8087c04297732f9daa17952677fdb41a8d5ce68482ec38f8cb3469b57/polars_interval_match-0.1.31-cp311-cp311-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a6286356aa8a1184a1cb892b289a2edd72c828957d4c01d833f5e5613966656f",
"md5": "d8286419b114ddbaa4c64019778aaa47",
"sha256": "0354e50d709c72f581b0400edc04401094a19ddb7aa11fa82c87cb201f0d2002"
},
"downloads": -1,
"filename": "polars_interval_match-0.1.31.tar.gz",
"has_sig": false,
"md5_digest": "d8286419b114ddbaa4c64019778aaa47",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 26654,
"upload_time": "2024-11-26T20:05:52",
"upload_time_iso_8601": "2024-11-26T20:05:52.425728Z",
"url": "https://files.pythonhosted.org/packages/a6/28/6356aa8a1184a1cb892b289a2edd72c828957d4c01d833f5e5613966656f/polars_interval_match-0.1.31.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-26 20:05:52",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "polars-interval-match"
}