Standalone categorical utility functions that complement the Series.cat accessor.
Mirrors pd.Categorical.from_codes, set operations on categories, frequency helpers,
and cross-tabulation.
catFromCodes(codes, categories, opts?)
Construct a categorical Series from integer codes (0-based) and a categories array.
Code -1 maps to null (missing). Mirrors
pd.Categorical.from_codes.
catUnionCategories, catIntersectCategories,
catDiffCategories, and catEqualCategories let you
combine or compare the category sets of two Series.
catSortByFreq(series, opts?)
Reorder categories by their frequency in the data (most frequent first by default).
Mirrors s.cat.reorder_categories(s.value_counts().index).
catToOrdinal(series, order)
Create an ordered categorical from a Series using order to define both the
category set and their rank. Values not in order become null.
catFreqTable(series)
Return a plain Record<string, number> of counts per category.
Zero-frequency categories are included.
catCrossTab(a, b, opts?)
Cross-tabulation of two categorical Series. Rows = a's categories,
columns = b's categories, cells = co-occurrence counts.
Supports margins and normalization.
catRecode(series, mapping)Rename categories via an object map or a transform function. Unmapped categories are left unchanged.