# Tables People Can Read

A table in a report keeps only the columns a reader needs, renames them in plain words, rounds its numbers, shows the top ten instead of every row, and uses df.style.format to show money as $20.00 and shares as 97.2% with the index hidden.

Journeyman · Python · Updated November 19, 2026

By Gregor Dzierzon

## After this lesson you can

- Make a table readable by keeping the columns a reader needs, renaming them, rounding, and showing the top ten
- Format money and percentages with df.style.format, and hide the index with hide(axis='index')

## Key takeaways

- Keep only the columns the reader needs, and rename them in plain words with rename(columns={...}).
- Round numbers to what a reader can use, and show the top ten with sort_values and head(10), or nlargest, instead of every row.
- df.style.format shows money and percentages the way people read them, such as $20.00 and 97.2%, and hide(axis="index") drops the row labels.
- df.style changes how a table looks, not its numbers, and it needs the Jinja2 package, which nbconvert installs.

The tables pandas prints are made for you, the person writing the code: every column, names with underscores, numbers to six decimal places. In a report, a table like that makes the reader do the work. Whenever a table goes in front of someone else, a manager, a client or a class, a few steps turn it into one they can read at a glance.

The example is Pine Valley Community Center's classes, `classes.csv`, one row for each of its 588 class sessions from November 2025 to October 2026. Denise, the director, asks: which classes fill up, and what do they cost?

## A table made for the code, not the reader

A summary with one row per class has the answer in it:

```python
import pandas as pd

classes = pd.read_csv("classes.csv")
by_class = classes.groupby("class_name", as_index=False).agg(
    category=("category", "first"),
    sessions=("class_id", "count"),
    capacity=("capacity", "sum"),
    signed_up=("signed_up", "sum"),
    fee=("fee", "first"),
)
by_class["fill"] = by_class["signed_up"] / by_class["capacity"]
by_class.head(4)
```

```text
         class_name    category  sessions  capacity  signed_up   fee      fill
0  Acrylic Painting        arts        24       288        197  15.0  0.684028
1   Computer Basics  technology         6        60         55   0.0  0.916667
2      Junior Chess        kids        24       288        183   0.0  0.635417
3     Kids Art Club        kids        48       768        684   5.0  0.890625
```

VS Code draws the table as a grid; this lesson shows it as pandas prints it as text. Denise has to work out that `fill` is the share of seats taken, that `0.684028` means about 68%, that `15.0` is dollars, and that the classes are in A to Z order, not best first. All 15 classes are in the full table, seven columns wide, and she needs two of the columns.

## Fewer columns, names for readers

Keep only what answers the question, then give each column a name a person would say. **`rename()`** takes a dictionary, old name to new name:

```python
table = by_class[["class_name", "fee", "fill"]]
table = table.rename(columns={"class_name": "Class", "fee": "Fee", "fill": "Seats filled"})
table.head(3)
```

```text
              Class   Fee  Seats filled
0  Acrylic Painting  15.0      0.684028
1   Computer Basics   0.0      0.916667
2      Junior Chess   0.0      0.635417
```

Rename for the report only. In your code, `fill` is easier to type than `Seats filled`, so make the renamed table at the end, right before it's shown.

## Rounding and the top ten

A reader can't use six decimal places, and 15 rows is already more than most people scan. Sort the best first, keep ten, and round:

```python
top = table.sort_values("Seats filled", ascending=False).head(10)
top["Seats filled"] = top["Seats filled"].round(3)
top
```

```text
                  Class   Fee  Seats filled
11  Summer Science Camp  20.0         0.972
9     Smartphone Basics   0.0         0.942
1       Computer Basics   0.0         0.917
7         Pottery Wheel  25.0         0.914
3         Kids Art Club   5.0         0.891
5         Little Movers   5.0         0.876
10                 Spin  10.0         0.858
6          Morning Yoga   8.0         0.814
13    Watercolor Basics  15.0         0.778
8       Senior Strength   0.0         0.721
```

Three decimal places of a share is a tenth of a percent: 0.972 is 97.2%. **`nlargest()`** is a shorter way to get the same ten rows: `table.nlargest(10, "Seats filled")`. With 588 sessions, or 600 rows of anything, "the top ten" is a table someone reads; all of them is a table someone skips.

The numbers down the left, 11, 9, 1, are the old row labels, the index. They mean nothing to Denise.

## Money and percentages with df.style.format

Every DataFrame has a **`style`** property that makes a **Styler**: the same table, drawn for people. Its `format()` method takes a dictionary of column names and format codes, and `hide(axis="index")` leaves out the row labels:

```python
top.style.format({"Fee": "${:.2f}", "Seats filled": "{:.1%}"}).hide(axis="index")
```

In a notebook, the cell shows this table:

| Class | Fee | Seats filled |
|---|---|---|
| Summer Science Camp | $20.00 | 97.2% |
| Smartphone Basics | $0.00 | 94.2% |
| Computer Basics | $0.00 | 91.7% |
| Pottery Wheel | $25.00 | 91.4% |
| Kids Art Club | $5.00 | 89.1% |
| Little Movers | $5.00 | 87.6% |
| Spin | $10.00 | 85.8% |
| Morning Yoga | $8.00 | 81.4% |
| Watercolor Basics | $15.00 | 77.8% |
| Senior Strength | $0.00 | 72.1% |

The format codes are Python's, the ones f-strings use. `"${:.2f}"` is a dollar sign, then the number with two decimal places (`.2f`, read "point two f"). `"{:.1%}"` multiplies by 100 and adds a percent sign, with one decimal place.

The Styler changes only how the table looks: `top["Seats filled"]` still holds `0.972`, so keep computing with `top` and show the Styler. A Styler is drawn as a web table, so it shows in the notebook and in a web page made from it. It needs the **Jinja2** package, which nbconvert installs; without it, `.style` stops with `AttributeError: The '.style' accessor requires jinja2`.

## Check yourself

2 questions to try on the lesson page.

## So what

A table in a report answers the reader's question and nothing else: the columns they need, in words they'd use, the top rows, and numbers shown as money and percentages.

## Key terms

- [rename()](https://www.ask-codey.com/glossary/rename)
- [nlargest()](https://www.ask-codey.com/glossary/nlargest)
- [Styler](https://www.ask-codey.com/glossary/styler)

## Related

- [A Notebook That Tells a Story](https://www.ask-codey.com/lessons/data-notebook-that-tells-a-story)
- [What the Data Can and Can't Show](https://www.ask-codey.com/lessons/data-what-the-data-cant-show)

Source: https://www.ask-codey.com/lessons/data-tables-people-can-read
