Skip to content

4.0. Tables

What is Great Tables?

great_tables is a Python library designed to make beautiful, well-formatted tables for your analysis outputs.
It’s especially useful when you want to share results with stakeholders - whether that’s a report, a presentation, or an email - without sending them raw Excel files or unformatted console prints.

Think of it as a way to present your data like a polished dashboard table, but entirely in Python.


Why use it in pricing workflows?

In insurance pricing, results are often shared in tables - for example:

  • Premium summaries by segment
  • Loss ratio breakdowns by product or region
  • Model performance comparison tables

In Excel, these tables can be manually formatted, but that’s time-consuming and error-prone.
With great_tables, you can automatically generate attractive, consistent tables straight from your Python code, keeping the formatting reproducible and avoiding manual edits.


Installing Great Tables

import pandas as pd
from great_tables import GT

# Example data
df = pd.DataFrame({
    "Product": ["Motor", "Home", "Travel"],
    "Earned Premium (£)": [1_200_000, 800_000, 300_000],
    "Claims (£)": [950_000, 500_000, 200_000],
})

df["Loss Ratio"] = df["Claims (£)"] / df["Earned Premium (£)"]

# Create a Great Table
GT(df)\
    .fmt_currency(columns=["Earned Premium (£)", "Claims (£)"], currency="GBP")\
    .fmt_percent(columns="Loss Ratio", decimals=1)\
    .tab_header(
        title="Loss Ratio by Product",
        subtitle="Based on 2024 policy year"
    )