Skip to main content

freetable

Coverage

Convert regression results (statsmodels or pyfixest) to publication-ready LaTeX tables. This package is highly opinionated and seeks to do exactly one thing well.

Moreover, unlike many similar packages, this one is completely free to use and imposes no requirements on users (read more here about problems with other packages).

Example regression table output

Installation

pip install -U freetable

You'll also need either statsmodels or pyfixest (or both):

pip install statsmodels  # for statsmodels support
pip install pyfixest     # for pyfixest support

Or use optional dependency groups:

pip install freetable[statsmodels]  # includes statsmodels
pip install freetable[pyfixest]     # includes pyfixest
pip install freetable[all]          # includes both

Features

  • Clean, opinionated output using modern LaTeX packages
  • Automatic significance stars (default: *** p < 0.001; ** p < 0.01; * p < 0.05)
  • Customizable significance thresholds
  • Variable renaming for clean presentation
  • Standard errors in parentheses below coefficients
  • R², adjusted R², and number of observations
  • Extra custom rows (e.g., outcome labels, SE types, subsets)
  • Grouped column headers with multicolumn support
  • Customizable table placement
  • Optional automatic resizing for wide tables
  • Professional formatting with booktabs, siunitx, and threeparttable

Requirements

Python:

  • statsmodels (for statsmodels support) OR
  • pyfixest (for pyfixest support)

LaTeX packages:

  • threeparttable
  • siunitx
  • booktabs
  • tabularx
  • graphicx (only required if using resize=True)

Add these to your LaTeX document preamble:

\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{threeparttable}
\usepackage{tabularx}
\usepackage{graphicx}  % Only needed for resize=True

Or just use paper!

Supported Libraries

freetable supports regression results from:

  • statsmodels - OLS, WLS, GLS, and other linear models
  • pyfixest - High-performance fixed effects estimation

You can use models from either library interchangeably, or even mix them in the same table!

Usage

See examples/ for the output generated by the following code.

Basic example (statsmodels)

import pandas as pd
import statsmodels.formula.api as smf
from freetable import tabularx

df = pd.read_csv("output.csv")

# Fit your models
m1 = smf.ols("y ~ x1", data=df).fit()
m2 = smf.ols("y ~ x1 + x2", data=df).fit()

# Generate LaTeX table
latex = tabularx(
    [m1, m2],
    model_names=["Model 1", "Model 2"],
    caption="Regression Results",
    label="tab:regression",
    digits=3,
    rename={"x1[T.Male]": "Male", "x2": "Age"},
    stars=(0.1, 0.05, 0.01),  # Order doesn't matter - automatically sorted
)

print(latex)

Did you know? You can replace tabularx by tabularray!

Advanced example with all features

import pandas as pd
import statsmodels.formula.api as smf
from freetable import tabularx

df = pd.read_csv("data.csv")

# Fit three models
m1 = smf.ols("outcome ~ treatment", data=df).fit(cov_type="HC3")
m2 = smf.ols("outcome ~ treatment + control1", data=df).fit(cov_type="HC3")
m3 = smf.ols("outcome ~ treatment + control1 + control2", data=df).fit(
    cov_type="cluster",
    cov_kwds={"groups": df["cluster_id"]},
)

# Create comprehensive table
latex = tabularx(
    [m1, m2, m3],
    model_names=["Model 1", "Model 2", "Model 3"],
    caption="Treatment Effects on Outcomes",
    label="tab:treatment",
    digits=3,
    rename={"treatment": "Treatment", "control1": "Control 1", "control2": "Control 2"},
    extra_rows={
        "Outcome": ["Y", "Y", "Y"],
        "Subset": ["All", "All", "All"],
        "SE type": ["HC3", "HC3", "Clustered"],
    },
    custom_header=[("Main Effects", 2), ("Full Model", 1)],
    placement="h!",
    resize=False,
)

print(latex)

Development

This package uses the following tools for code quality and consistency:

  • black: Code formatting
  • ruff: Fast Python linting
  • isort: Import sorting
  • mypy: Static type checking
  • pytest: Testing framework

Running tests

Install development dependencies:

pip install -Ue ".[dev]"

Run tests:

pytest

Run type checking:

mypy src/freetable/

License

Everything in this repository is licensed under CC0 1.0 Universal, or (at your option) any later version. See LICENSE for details. Note that there is absolutely no warranty.

Metadata

Release files for freetable 3.0.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 freetable 3.0.0
File Size Uploaded
freetable-3.0.0.tar.gz 152.2 kB Details

Built distribution (wheel)

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

Total release size: 164.6 kB

Release files / freetable-3.0.0.tar.gz

Download URL freetable-3.0.0.tar.gz
Size 152.2 kB
Tags Source
SHA-256 checksum
How to use checksums
899db68d36c37e2458cc966a540e1185268fb98180f6904d04bca1b4391fabe5
BLAKE2b-256 checksum
How to use checksums
5ec4f062b20d1f1a7daa76cd04d5751be4ea77c0725f5082d28ef25cfb2db779
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / freetable-3.0.0-py3-none-any.whl

Download URL freetable-3.0.0-py3-none-any.whl
Size 12.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6952416c48b7b372931566bb74f61b162fb130900b8aac14ea131f60ec61fc9b
BLAKE2b-256 checksum
How to use checksums
87c56336d60e0ce36172333dc0ad2d192b59a3db226753743f27e331efad6687
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files

2.0.0

2 release files

1.1.0

2 release files

1.0.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