Skip to main content

Polarsgrid

Continuous integration PyPI - Python Version

Tidyverse-style expand_grid() in a fast and efficient way using Polars.

Installation

Install the package as follows:

pip install polarsgrid

or add it to your project using uv as follows:

uv add polarsgrid

Usage

This package contains one main function: expand_grid().

from polarsgrid import expand_grid
expand_grid(a=range(2), b=["x", "y"])
shape: (4, 2)
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ i64 ┆ str │
╞═════╪═════╡
│ 0   ┆ x   │
│ 1   ┆ x   │
│ 0   ┆ y   │
│ 1   ┆ y   │
└─────┴─────┘

Note that the first argument iteratest fastest, and the last argument iterates slowest in the cartesian product.

Should the grid become too big to hold in memory, you can choose to return a lazy table which can be stored on a disk efficiently:

from polarsgrid import expand_grid_lazy
lgrid = expand_grid_lazy(
    sample_size=range(1000), 
    condition=["a", "b", "c"], 
    iteration=range(500), 
)
lgrid.sink_parquet("grid.parquet")

Additionally, for certain operations it might be nice to return the string columns as a categorical data type, and to add a row id:

expand_grid(
    fruit=["apple", "banana", "pear"], 
    color=["red", "green", "blue"], 
    check=[True, False], 
    _categorical=True,
    _row_id=True,
)
shape: (18, 4)
┌────────┬────────┬───────┬───────┐
│ row_id ┆ fruit  ┆ color ┆ check │
│ ---    ┆ ---    ┆ ---   ┆ ---   │
│ i64    ┆ cat    ┆ cat   ┆ bool  │
╞════════╪════════╪═══════╪═══════╡
│ 0      ┆ apple  ┆ red   ┆ true  │
│ 1      ┆ banana ┆ red   ┆ true  │
│ 2      ┆ pear   ┆ red   ┆ true  │
│ 3      ┆ apple  ┆ green ┆ true  │
│ 4      ┆ banana ┆ green ┆ true  │
│ …      ┆ …      ┆ …     ┆ …     │
│ 13     ┆ banana ┆ green ┆ false │
│ 14     ┆ pear   ┆ green ┆ false │
│ 15     ┆ apple  ┆ blue  ┆ false │
│ 16     ┆ banana ┆ blue  ┆ false │
│ 17     ┆ pear   ┆ blue  ┆ false │
└────────┴────────┴───────┴───────┘

Metadata

Release files for polarsgrid 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polarsgrid 0.4.0
File Size Uploaded
polarsgrid-0.4.0.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for polarsgrid 0.4.0
File Interpreter ABI Platform
polarsgrid-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / polarsgrid-0.4.0.tar.gz

Download URL polarsgrid-0.4.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cc1a67c2be336d75bf0595fa788cb40a7f506975b4025c381340b23255e5b3ce
BLAKE2b-256 checksum
How to use checksums
1f86efd3bd3a51f8c998b1bd9bbc6831bc649d6e2335ff2218d375ff7a17df0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 9, 2026.

Transparency log

Release files / polarsgrid-0.4.0-py3-none-any.whl

Download URL polarsgrid-0.4.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c1e6328515194020e7a8132f2392585393c10942117fcebde55719bfdb5fa4a8
BLAKE2b-256 checksum
How to use checksums
aee0a440ad519705fa5f7615b46312153175ac0966e5cdc36fa7e0d9f38b393f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page