Skip to main content

MakeTables

PyPI - Version Python Versions License Tests Downloads Downloads File an Issue

Docs · Function & API Reference · Report Bugs & Request Features · Adding Support for new Model Classes

A Python package for creating publication-ready tables from regression results (statsmodels, pyfixest, linearmodels), descriptive statistics, and balance tables with output to LaTeX, Word, Typst and HTML (HTML tables are created with Great Tables). To get started, check out the Getting Started Notebook.

Overview

MakeTables provides a unified interface for generating tables such as:

The package supports multiple output formats including:

  • Great Tables (HTML)
  • LaTeX
  • Microsoft Word (docx) documents
  • Typst

Model Support

maketables supports creating regression tables for models from the following packages:

It is very easy to add support for new models - either in the maketables code base, or from within your own package via a maketables plug-in. For example, ModernDiD supports maketables for its difference-in-differences estimators this way (see its guide on publication tables). Take a look at the docs to get started, and please feel free to reach out for help!

Supporting maketables in your own package

Add these attributes to your result class; your package does not need to import maketables:

@property
def __maketables_coef_table__(self) -> pd.DataFrame:  # required
    # index: coefficient names; columns: b, se, p (optional: t, ci95l, ci95u, ...)
    return pd.DataFrame({"b": self.params, "se": self.bse, "p": self.pvalues})


def __maketables_stat__(self, key: str):  # optional, e.g. "N", "r2"
    return {"N": self.nobs, "r2": self.rsquared}.get(key)


@property
def __maketables_depvar__(self) -> str:  # optional
    return self.depvar

Users can then pass your results directly to mt.ETable([...]). All attributes, statistic keys and a runnable example are in the plug-in specification.

Origin

MakeTables originated as the table output functionality within the pyfixest package and has been moved to this standalone package to provide broader table creation capabilities also supporting other statistical packages.

Authors

Installation

From PyPI

pip install maketables

Development Installation

# Clone the repository
git clone https://github.com/yourusername/maketables.git
cd maketables

# Install in development mode
pip install -e .

Quick Start

Descriptive Statistics Table

import pandas as pd
import maketables as mt

# Load your data (here using a sample Stata dataset with the import_dta function that also stores variable labels)
df = mt.import_dta("https://www.stata-press.com/data/r18/auto.dta")


# Create descriptive statistics table
mt.DTable(df, vars=["mpg", "weight", "length"], bycol=["foreign"])

Regression Tables

with pyfixest

import pyfixest as pf

# Fit your models here using pyfixest
est1 = pf.feols("mpg ~ weight", data=df)
est2 = pf.feols("mpg ~ weight + length", data=df)

# Make the table
mt.ETable([est1, est2])

with statsmodels

import statsmodels.formula.api as smf

# Generate a dummy variable and label it
df["foreign_i"] = (df["foreign"] == "Foreign") * 1
mt.set_var_labels(df, {"foreign_i": "Foreign (indicator)"})

# Fit your models
est1 = smf.ols("foreign_i ~ weight + length + price", data=df).fit()
est2 = smf.probit("foreign_i ~ weight + length + price", data=df).fit(disp=0)

# Make the table
mt.ETable(
    [est1, est2],
    model_stats=["N", "r2", "pseudo_r2", ""],
    model_heads=["OLS", "Probit"],
)

Main Classes

MTable

Base class for all table types with common functionality:

  • Multiple output formats (Great Tables, LaTeX, Word)
  • Flexible styling and formatting options
  • Save and export capabilities
  • Can also update tables in existing word documents
  • Adapted for use in Jupyter Notebooks and for quarto use (tables automatically rendered as html in notebooks and as latex when rendering to pdf in quarto)

DTable

Extends MTable for descriptive statistics:

  • Automatic calculation of summary statistics
  • Grouping by categorical variables (rows and columns)
  • Customizable statistic labels and formatting

ETable

Extends MTable for econometric model results:

  • Support for statsmodels, pyfixest, and (more experimental) linearmodels
  • Many layout options (relabelling of variables, keep/drop, choice of reported statistics, column headings,...)

BTable

Extends MTable for simple balance tables.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Metadata

Release files for maketables 0.2.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 maketables 0.2.0
File Size Uploaded Provenance Actions
maketables-0.2.0.tar.gz 80.9 kB Without provenance Details for maketables-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 161.8 kB

Release files / maketables-0.2.0.tar.gz

Download URL maketables-0.2.0.tar.gz
Size 80.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0db51b7efa1e6ed8b1aedcd0537d8692ea8699ed08557e1871a5413a374c7058
BLAKE2b-256 checksum
How to use checksums
a08a6a4e741bb84430182eea62648276cab49f13ae4732d8f348d85180e0aa04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / maketables-0.2.0-py3-none-any.whl

Download URL maketables-0.2.0-py3-none-any.whl
Size 81.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9c25cff923ab70c10502197d338c358bd1a7edd116038098913fc908eff82e2
BLAKE2b-256 checksum
How to use checksums
fd3e4c5bee40c906e601374f485990f9afef71b40853d73f25a345ee9d4b79c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Security for maketables 0.2.0

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.

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