Skip to content

polars-statistics API Reference

Complete API documentation for polars-statistics.

Category Description
Conventions API patterns, column references, return types
Statistical Tests
Parametric Tests t-tests, Brown-Forsythe, Yuen
Non-Parametric Tests Mann-Whitney, Wilcoxon, Kruskal-Wallis, Brunner-Munzel
Distributional Tests Shapiro-Wilk, D'Agostino normality tests
Forecast Tests Diebold-Mariano, Clark-West, SPA, MCS
Correlation Tests Pearson, Spearman, Kendall, distance correlation, partial correlation
Categorical Tests Chi-square, Fisher exact, McNemar, Cohen's Kappa
TOST Equivalence Two One-Sided Tests for equivalence
Regression
Linear Models OLS, Ridge, Elastic Net, WLS, RLS, BLS, NNLS, Quantile, Isotonic
GLM Models Logistic, Poisson, Negative Binomial, Tweedie, Probit, Cloglog
ALM Augmented Linear Model (24+ distributions)
Dynamic Models LmDynamic time-varying coefficients
Demand Classification AID demand patterns and anomaly detection
Formula Syntax R-style formulas with interactions and polynomials
Summary & Predict Coefficient tables and prediction intervals
Diagnostics Condition number, quasi-separation detection
Model Classes
Linear Model Classes OLS, Ridge, ElasticNet, WLS, RLS, BLS, Quantile, Isotonic
GLM Model Classes Logistic, Poisson, NegativeBinomial, Tweedie, Probit, Cloglog
ALM Class Augmented Linear Model class
LmDynamic Class Dynamic linear model class
Aid Class Demand classification class
Test Classes Statistical test classes
Bootstrap Classes Stationary and circular block bootstrap
Reference
Output Structures All return type definitions

Installation

pip install polars-statistics

Basic Usage

All functions work as Polars expressions:

import polars as pl
import polars_statistics as ps

df = pl.DataFrame({
    "group": ["A"] * 50 + ["B"] * 50,
    "y": [...],
    "x1": [...],
})

# Run regression per group
result = df.group_by("group").agg(
    ps.ols("y", "x1").alias("model")
)

# Extract results
result.with_columns(
    pl.col("model").struct.field("r_squared"),
)

See Also