Skip to main content

Generate LaTeX tables with Python

Project description


Generate LaTeX tables in Python from your data in a pandas.DataFrame.


All you need is a dataframe you'd like to create a table for, and a list of TableColumns for each column in the dataframe you would like to include in your table.

import pandas as pd
from tabla import TableColumn, Table

columns = [
    TableColumn("date", "", "%Y-%m-%d", "Date"),
    TableColumn("temp", "(degrees)", "{:0.2}", "Temperature"),
    TableColumn("rate", r"(m day\textsuperscript{-1})", "{:04.3}", "Rate"),

dates = pd.date_range("2020-01-01", "2020-01-02", freq="6H")
data = list()
for date in dates:
    d = {"date":date}
    d.update({c: for c in ["temp", "rate"]})

df = pd.DataFrame(data)

table = Table("test_name", columns, dataframe, header_units=True)

# Generate as a string
latex_str = table.dumps()

Project details

Download files

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

Files for tabla, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size tabla-0.0.1.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page