catfact
Categorical wrangling for Python. Supports both Polars and Pandas. Enables categorical and ordinal scales in plotting tools like Plotnine.
catfact addresses some common challenges when working categorical data. Categorical data is useful when you want to display your data in a specific way, like alphabetical, most frequent first, or along a scale. It is a port of the popular R package forcats.
Installation
pip install catfact
Basic example
import polars as pl
import catfact as fct
from catfact.polars.data import starwars
(
starwars
.group_by("eye_color")
.agg(pl.len())
.sort("len", descending=True)
)
| eye_color | len |
|---|---|
| str | u32 |
| "brown" | 21 |
| "blue" | 19 |
| "yellow" | 11 |
| "black" | 10 |
| "orange" | 8 |
| … | … |
| "white" | 1 |
| "pink" | 1 |
| "blue-gray" | 1 |
| "green, yellow" | 1 |
| "dark" | 1 |
from plotnine import ggplot, aes, geom_bar, coord_flip
(
ggplot(starwars, aes("eye_color"))
+ geom_bar()
+ coord_flip()
)
(
starwars
.with_columns(
fct.infreq(pl.col("eye_color"))
)
>> ggplot(aes("eye_color"))
+ geom_bar()
+ coord_flip()
)
Release files for catfact 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| catfact-0.1.0.tar.gz | 348.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| catfact-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 370.3 kB
Release files / catfact-0.1.0.tar.gz
| Download URL | catfact-0.1.0.tar.gz |
|---|---|
| Size | 348.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
463a1de1574183a8965a298989f55ea412469660344f03c5de1b3f1c21ee332e
|
|
BLAKE2b-256 checksum How to use checksums |
f2985c04906bb1390aad45675bec1bc5ee5bde4e4703dc67ab58970b03c82382
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Jun 24, 2025.
Transparency logRelease files / catfact-0.1.0-py3-none-any.whl
| Download URL | catfact-0.1.0-py3-none-any.whl |
|---|---|
| Size | 21.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab8c70a6939ed38e934f72b87e6c1557a7a91f0f55c409d779d7fd9a633517d4
|
|
BLAKE2b-256 checksum How to use checksums |
4ecf109d3bb60863bb3427383d12329c6ac28f3fe2787983d8561d1c9600e0ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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 Jun 24, 2025.
Transparency log