Skip to main content

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())

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_grouper-0.1.0.tar.gz (19.4 kB view hashes)

Uploaded Source

Built Distributions

polars_grouper-0.1.0-cp38-abi3-win_amd64.whl (3.3 MB view hashes)

Uploaded CPython 3.8+ Windows x86-64

polars_grouper-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ x86-64

polars_grouper-0.1.0-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl (4.0 MB view hashes)

Uploaded CPython 3.8+ manylinux: glibc 2.17+ i686

polars_grouper-0.1.0-cp38-abi3-macosx_11_0_arm64.whl (3.1 MB view hashes)

Uploaded CPython 3.8+ macOS 11.0+ ARM64

polars_grouper-0.1.0-cp38-abi3-macosx_10_12_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.8+ macOS 10.12+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page