ngram_polars - N-Gram Generation for Polars
A high-performance Polars plugin for generating n-grams from text data in Python.
Installation
pip install ngram-polars
Basic example
import polars as pl
from ngram_polars import ngrams
df = pl.DataFrame({
"id": [1, 2],
"words": [
["the", "quick", "brown", "fox"],
["hello", "world"]
]
})
# Generate bigrams
result = df.with_columns(
bigrams=ngrams(pl.col("words"), n_range=[2])
)
more advanced examples
# Multiple n-gram sizes
df.with_columns(
multi_ngrams=ngrams(pl.col("words"), n_range=[1, 2, 3])
)
# Custom delimiter
df.with_columns(
underscored=ngrams(pl.col("words"), n_range=[2], delimiter="_")
)
# Lazy evaluation
(df.lazy()
.with_columns(
ngrams=ngrams(pl.col("words"), n_range=[2, 3])
)
.collect()
)
API Reference
ngrams(expr, n_range, delimiter)
Generate n-grams from a list of strings.
Parameters:
expr: IntoExpr- Polars expression representing a list of stringsn_range: list[int]- List of n-gram sizes to generate (default: [1])delimiter: str- String delimiter between words (default: " ")
Returns:
pl.Expr- Expression that generates lists of n-gram strings
Behavior:
- Returns a new list column containing all generated n-grams
- Works element-wise on list columns
- Changes the length of the output (each input list produces a new list of n-grams)
- Supports both eager and lazy evaluation
Performance Tips
- Use Lazy Evaluation: For large datasets, use lazy evaluation to optimize query planning
- Batch N-Gram Sizes: Generate multiple n-gram sizes in one call when possible
- Choose Appropriate N-Range: Only generate the n-gram sizes you actually need
Requirements
- Python 3.10 -> 3.14
- Polars requirement are not fully tested, tested on the latest version.
- Compatible with both eager and lazy Polars APIs
Changes
0.1.2: Updated to Rust 1.93.1 and Polars 0.53.0 (dropped python 3.9 added 3.14)
Metadata
Release files for ngram-polars 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ngram_polars-0.1.3.tar.gz | 28.2 kB | Without provenance | Details for ngram_polars-0.1.3.tar.gz |
Built distributions (wheels)
Total release size: 98.0 MB
Release files / ngram_polars-0.1.3.tar.gz
| Download URL | ngram_polars-0.1.3.tar.gz |
|---|---|
| Size | 28.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
71da83af00ba399830fe1f3af0aac22bae561f6f2a55f5e68bc161abd11bb8b1
|
|
BLAKE2b-256 checksum How to use checksums |
e44d81ef59ec18e6da04ee65d772b328091e5ce5a41326dea55883885a21492e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp314-cp314-win_amd64.whl
| Download URL | ngram_polars-0.1.3-cp314-cp314-win_amd64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | CPython 3.14 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
aa5fc61bbc500d25362a74cd8c1041a0ce7b298da06c55bc81be35981400a9b6
|
|
BLAKE2b-256 checksum How to use checksums |
5e9f99b167d170ca49d9125d2c5e8773d29aa6aeb9967593cee22b7fdb06ecc1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ngram_polars-0.1.3-cp314-cp314-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
07ab8dd241515cab3e02ceb49e9d613356fbd7b6caec49bf6711b78f640f51e5
|
|
BLAKE2b-256 checksum How to use checksums |
6079ded66cc6e171b1423302ac2770550fa6de68d232b5fa542fc552c4c43d1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ngram_polars-0.1.3-cp314-cp314-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.14 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
90287de33051267a95cb49f3ff19f101e02f452bfd61628b1dfa4562f008cbf1
|
|
BLAKE2b-256 checksum How to use checksums |
ad40ae9104a15f63647dc37b2a01e266495c7972340af51177b54de4ebf4124c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp314-cp314-macosx_11_0_arm64.whl
| Download URL | ngram_polars-0.1.3-cp314-cp314-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.14 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
1731d0d259bb2abdc8417950b38712dfbc6e9e744ffa164e32f9a81146f3e916
|
|
BLAKE2b-256 checksum How to use checksums |
6f42ec1012f2bf12c3f9bb2d6171eeb1c9c09ff49f319bb73f15d49f4e13dc2a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp314-cp314-macosx_10_12_x86_64.whl
| Download URL | ngram_polars-0.1.3-cp314-cp314-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.14 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
3ed8b878b3f1544868a3d015dca989df3516d64f6f0aa5d494c761cd63688315
|
|
BLAKE2b-256 checksum How to use checksums |
67d35244a360e6c74ee6db57efd7560a277097518c0a64c9e9163410ec755128
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp313-cp313-win_amd64.whl
| Download URL | ngram_polars-0.1.3-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3c58d58cfed91a9debe1177ef8d068b7d12d703588374b31e764ff88e4beb96f
|
|
BLAKE2b-256 checksum How to use checksums |
d2d818e720045e37c1b51fb3343d54648f32f1babed92730c3d193cf5b9720af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ngram_polars-0.1.3-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7997f6f53924c27eb60ec77fb9c97353027d35899b5f9c976135fd534552d59c
|
|
BLAKE2b-256 checksum How to use checksums |
7da296fd33ef0e8dd139cb7f814d9426af2d4d3987e321f0e6ac2a881c8c7aa0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ngram_polars-0.1.3-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.13 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
7f8db3fc46442740a5c1d0f1f9598e8cf11db01b6f413254c829611f74c100c0
|
|
BLAKE2b-256 checksum How to use checksums |
81bfaf4b3b20c00774a066fd38ae452e111d776acdb055a48c3cc32e1880cf73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp313-cp313-macosx_11_0_arm64.whl
| Download URL | ngram_polars-0.1.3-cp313-cp313-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.13 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
50048017addfee1e44a979442631386123ccd5a339000213bee9dd6a9762e5a5
|
|
BLAKE2b-256 checksum How to use checksums |
b00a9b33b8672922553dd798fe7b293449c3c0d9b8cbeb307e0ed9b099e48688
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp313-cp313-macosx_10_12_x86_64.whl
| Download URL | ngram_polars-0.1.3-cp313-cp313-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.13 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
b468c6d2ee33270048552ab9daaedd28e500340bbd576a25d157a72051115652
|
|
BLAKE2b-256 checksum How to use checksums |
5a02e5418c48630d8b4f804c8387d8d6ff3a5b5557075c5f003c7006b2a23191
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp312-cp312-win_amd64.whl
| Download URL | ngram_polars-0.1.3-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
49c724227f2f55e32c15fc0a0bc52cf7a6d1b5590b44a2fb2a3fcd10eb82f1a8
|
|
BLAKE2b-256 checksum How to use checksums |
c75116046826a9d3e63951545bcd26560d13e66c3c6bff78a42324be2cda3d92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ngram_polars-0.1.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
5f1952bdb546dc6de0059234b63fcfb830295c6a9b377a145c88227567b9fdc2
|
|
BLAKE2b-256 checksum How to use checksums |
57260caf43cfb392b7c621d3efecda3c24d445ab08c724e8399d39a27018939a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ngram_polars-0.1.3-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.12 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
e5ecc0ca575e792c516a17053cca4dc746c14af299d32baab7359e35384c8c84
|
|
BLAKE2b-256 checksum How to use checksums |
5ec1b3483029407ac15b3ed3c337a0181c6996fad8160f49f8c32bcc1a29b11f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | ngram_polars-0.1.3-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
fd1ccac1a335009ab336ae76470d5102621bda42a28653283a0c21ba5aacfb8f
|
|
BLAKE2b-256 checksum How to use checksums |
713d757ca4a878ba2a6fb08b6a3cee7575237da6b5d65a022ac98a6e5ff92e7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp312-cp312-macosx_10_12_x86_64.whl
| Download URL | ngram_polars-0.1.3-cp312-cp312-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.12 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
137f497aa393e3973fce88766e82e71be10afe6ecd27f44d0639ba5410af6bdf
|
|
BLAKE2b-256 checksum How to use checksums |
d69baa3ca58d90a0c5e81117900448429976817f5a7994ec285d2ed454dd5eb6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp311-cp311-win_amd64.whl
| Download URL | ngram_polars-0.1.3-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b048f1e02c6a7f9abd155ed16764770fbc6d144072523f30d383da4aa4b113fc
|
|
BLAKE2b-256 checksum How to use checksums |
9914c8e40e18725082e878f703cce842602c67d0290b980a10f53cc622ce63fb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ngram_polars-0.1.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
2a8ec15066c714a996ddaeab56c984b1b18eedd7510eba147a80cb52c890cecf
|
|
BLAKE2b-256 checksum How to use checksums |
b2b9b3317302681a28600bf52751f6a6ea60b5c229b3c8c1aee5cb76ddb5f3f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ngram_polars-0.1.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.11 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
45ae62d14f919d8954cde15da8265a38041b23a6d039275cbcb9cdf747dfa8d9
|
|
BLAKE2b-256 checksum How to use checksums |
f7dde95931e63e05ce6c941cafe0d7d5c5e6407976033c5ed9a42dc8b918f9f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | ngram_polars-0.1.3-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
d5b709c6ce30c776ed23ecb4f27a7128960a6d9611b8a77c7767c0c61a3199fb
|
|
BLAKE2b-256 checksum How to use checksums |
a560ce251f45752890cf48f0a927fc44e9a92c4339532050153ffef5f690af95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp311-cp311-macosx_10_12_x86_64.whl
| Download URL | ngram_polars-0.1.3-cp311-cp311-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.11 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
73136b8228b1b6cb85a9e6cfcc1c3175c71ab17ab47f6aaf037239b60cbc8f01
|
|
BLAKE2b-256 checksum How to use checksums |
bfcef1be698571aefd677412c4a3292f81efcc1d2c173ff8d0b582927d52806b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp310-cp310-win_amd64.whl
| Download URL | ngram_polars-0.1.3-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 4.5 MB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
8b12a5c075c17114976bd482864134fc64c468364b59de9b15601be8df20b251
|
|
BLAKE2b-256 checksum How to use checksums |
d8250d4524d52a026ca255c7202c654e8f4c10304bdb19befbabc84e48d4ddf1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | ngram_polars-0.1.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
6fd4bbf12be3f92c6d8e3513319c89f3329da25d539c0a3f0311961f031d99ad
|
|
BLAKE2b-256 checksum How to use checksums |
079529cf9fcd67ae34fbd5d7177c4aaba203288c3909d06ab274af3932a2c46a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
| Download URL | ngram_polars-0.1.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl |
|---|---|
| Size | 3.7 MB |
| Tags | CPython 3.10 Linux glibc 2.17+ ARM64 |
|
SHA-256 checksum How to use checksums |
a15a9d0836ed2b23af91d01c89a06975d8345fd5c24cae4da5d9da53a5c7d5f7
|
|
BLAKE2b-256 checksum How to use checksums |
c1ecc7d423383349a34ebdb53c88e0052ef5dbce32c8e6d40fe873f62f378587
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | ngram_polars-0.1.3-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 3.4 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
5512caae4e1f4ac67629c16e8d49bb63ae48dc8504ada57b35cf1cb1e47c035f
|
|
BLAKE2b-256 checksum How to use checksums |
57134d4780f5ebefcc4f9edef8e37455615404dc009087121bd6da58290d7182
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / ngram_polars-0.1.3-cp310-cp310-macosx_10_12_x86_64.whl
| Download URL | ngram_polars-0.1.3-cp310-cp310-macosx_10_12_x86_64.whl |
|---|---|
| Size | 3.8 MB |
| Tags | CPython 3.10 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
686bff7d24c7a795c29281dc3db1fd1c3897c83b7e19101b066b2bf6939a9ed9
|
|
BLAKE2b-256 checksum How to use checksums |
a81af4c3a9a91d06d4e88d7beae392bd1e0c82a8f54db4db71a5a5a01438e7b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for ngram-polars 0.1.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.