Skip to main content

A Python package for creating publication-ready tables from regression results (statsmodels, pyfixest, linearmodels), descriptive statistics, and balance tables with output to LaTeX, Word, and HTML/Great Tables

Project description

MakeTables

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

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, HTML and Typst via 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. Take a look at the docs to get started, and please feel free to reach out for help!

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

maketables-0.1.8.tar.gz (69.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

maketables-0.1.8-py3-none-any.whl (72.3 kB view details)

Uploaded Python 3

File details

Details for the file maketables-0.1.8.tar.gz.

File metadata

  • Download URL: maketables-0.1.8.tar.gz
  • Upload date:
  • Size: 69.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for maketables-0.1.8.tar.gz
Algorithm Hash digest
SHA256 aa4b3776fd9bac6d6f881866824e6a13b9e647f8c87f234d9a24463242ad19f1
MD5 92a6bce5b5ea68a8570f90b7f1336bc5
BLAKE2b-256 7a7082a24141e18b25b1c70ad3b8389f28c3d49a56f289be4b0247977a7202d1

See more details on using hashes here.

File details

Details for the file maketables-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: maketables-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 72.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for maketables-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 d79aeb0c08ae8ed7d78978b5676ff1a5236517abbbd287b04986602504b0bfb5
MD5 d3e6d20f83d36c255bcb799268736892
BLAKE2b-256 accb7ef3503279a4d2dc6b7fed0d0c53a9d97d98f7c28166ebfcc45eef64fe29

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page