Graph solving and grouping extension for Polars DataFrames
Project description
PolarsGrouper
PolarsGrouper is a Rust-based extension for Polars that efficiently groups connected components in dataframes for graph analysis.
Features
- Group connected components in dataframes.
- High performance using Rust and Polars.
- Works with both eager and lazy Polars DataFrames.
Installation
To install PolarsGrouper, use pip
:
pip install polars-grouper
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate
# Build and install using maturin
maturin develop
Usage
graph_solver Register the graph_solver function:
import polars as pl
from polars_grouper import graph_solver
df = pl.DataFrame({
"from": ["A", "B", "C"],
"to": ["B", "C", "D"]
})
result_df = df.with_columns(
graph_solver(pl.col("from"), pl.col("to")).alias("group")
)
print(result_df)
Super_merger
Use super_merger to add connected component group information to a dataframe:
from polars_grouper import super_merger
import polars as pl
df = pl.LazyFrame({
"from": ["A", "B", "C"],
"to": ["B", "C", "D"]
})
result_df = super_merger(df, "from", "to")
print(result_df.collect())
Performance
Comparing the rust implementation with the native python options, the rust version outperforms the Python implementations significantly:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
polars_grouper-0.2.0.tar.gz
(16.9 kB
view hashes)
Built Distributions
Close
Hashes for polars_grouper-0.2.0-cp38-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9919f7880f8d8476879a634358e7795875119806f440b4f881e2b644a99f0d8 |
|
MD5 | 44b215866e508f5edb86f4d2f0c44e9e |
|
BLAKE2b-256 | 6262ef587b583065fcc0c5339bb5a5f0cc1d61b30ee65e0b89bc8cebb2e92160 |
Close
Hashes for polars_grouper-0.2.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0bf39a829c912d10a78d65978996e59ad1d64b4e94e52e6310a58417a810226 |
|
MD5 | 6b74d98f771cb5df071d09ff92a404dd |
|
BLAKE2b-256 | 06c13b313a21a5ebb411a3e92eb993d48f2291cb095bbc6edeb4632785b68ec8 |
Close
Hashes for polars_grouper-0.2.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10f48d915e32e366de78e376095c0db9eb9ad7e5b31aeef9ff07663e5fbc452f |
|
MD5 | 77e4041cb2fc58e7b3c5cd4a19355a92 |
|
BLAKE2b-256 | c218e98a50520dd3269eca6a42bea77778d86d3805eb7b67bd1dda2a7111ccbf |
Close
Hashes for polars_grouper-0.2.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 873e29369fd159bc38437c44ffc09186cdf03fb71de3708614900dafa303582b |
|
MD5 | e8ebc2e5eeb9f22b566aef22861115c8 |
|
BLAKE2b-256 | 8fdaa64e2483fb5a854cd699758cc2a51962e52b600fe55c85246c15363f7f94 |
Close
Hashes for polars_grouper-0.2.0-cp38-abi3-macosx_10_12_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | abecde0f1d778a381f5623f7181d5b85d507ab30183ed2ee951ae668873bbaf3 |
|
MD5 | 2b12e4c95b46654b0faf7ab89ca04831 |
|
BLAKE2b-256 | c230caea7bb4b02fc4e53daeec95f7bdcb22e1a5d65e2086137630d55e94da9e |