Aller au contenu

Leçon 11 · Tables and Charts

Formatting Numbers, Dates and Labels

Format report values clearly: rounding and precision, large numbers, currencies, percentages, negative values, international dates, labels and units in Python.

Formatting is not decoration. The way you write a number tells the reader how large it is, how exact it is and what unit it has. Small inconsistencies, such as mixing thousands and millions, can cause serious misreadings. This lesson gives practical rules, especially for reports that cross countries.

Choose precision on purpose

More decimals do not mean more accuracy. "Revenue: 1,284,339.47" suggests that the last cents matter to the decision. For a leadership page, "USD 1.28 million" is usually easier to read. In a reconciliation table, the exact cents may be essential.

Use Typical precision
Headline value Two or three significant digits, such as 1.28 M
Operational table Whole units
Financial reconciliation Full precision of the currency
Percentages Zero or one decimal, depending on size

These are habits, not rules. Pick the precision that lets readers see differences that matter, and no more. If two values both round to 4% but the difference matters, show one more decimal.

Large numbers and units

Choose one scale per table or chart and write it in the header: "Sales (USD thousands)". Do not mix "980K" and "1.2M" in the same column. Define abbreviations, because "M" and "MM" mean different things in different fields.

Currencies, countries and separators

  • Write currency codes such as USD, EUR or INR where readers may use different currencies. A "$" sign alone can mean several currencies.
  • If you convert currencies, state the rate source and rate date.
  • Decimal and thousands separators vary: some readers write 1.234,5 and others 1,234.5. Use the convention of your audience, and say which one if the audience is mixed.
  • Some regions group digits differently, for example in lakhs and crores. Follow the reader's convention.

Dates and periods

A date such as 03/04/2026 is April 3 for some readers and March 4 for others. Write month names ("3 Apr 2026" or "Apr 3, 2026") or the ISO 8601 form 2026-04-03. Label periods fully: "Week 48 (23 to 29 Nov 2026)". If your organization uses a fiscal year that differs from the calendar year, define it. Include the time zone when time of day matters.

Negative numbers and signs

Use a minus sign, or parentheses if your finance audience expects them, and be consistent. For changes, show the sign (+4.2% and -1.3%). A minus sign is easy to miss in small print, so do not rely on red text alone.

A formatting helper

Put formatting in one function so that every part of a report agrees. This example uses only the standard library.

Python One formatting function for the whole report

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The helper handles zero bases, missing old values and negative money. One known edge remains: a value just below one million can print as "1000.0 K". Add a test and a rule for it if your numbers get that large.

Rounding and totals

Rounded parts may not add to the rounded total. For example, shares of 33.4%, 33.3% and 33.3% show as 33% each and add to 99%, while the unrounded total is 100%. Calculate totals from unrounded values, round at the end and add a footnote such as "Figures may not add due to rounding."

Different tools round halves differently. Python's round uses "round half to even" for exact ties, and binary floating-point storage means that some decimal values are not exactly ties. For money, use decimal arithmetic and state your rounding rule.

Python Floats, ties and Decimal

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Labels in plain language

Replace system names with words readers use: "Orders awaiting payment" instead of ord_status_2. Keep one term for one idea throughout the report. Spell out an abbreviation the first time. Add the population when it is not obvious, for example "Customers (with at least one order)".

Write a style sheet

When several people produce reports, formats drift apart: one page says "Nov-26", another "November 2026", and a third rounds money differently. A short style sheet settles these choices once. This is an illustrative example.

TEXT
Currency:     code before value (USD 1.28 M); reporting currency USD
Large values: K and M, one scale per column
Percentages:  one decimal; differences in "points"
Dates:        3 Dec 2026 in text; 2026-12-03 in files
Weeks:        Monday to Sunday, shown with start and end date
Negatives:    minus sign
Missing:      "--" with a footnote; "n/a" when not applicable
Time zone:    UTC, named in the page header

Keep it to one page so that people actually read it. Where your tool supports shared formats, themes or functions, implement the rules there, because built-in rules are followed more reliably than written ones. Review the sheet when your audience changes, for example when a report starts going to a second country. A separator or date order that was obvious to the first group may mislead the second. When you change a rule, change every report that uses it at the same time, or readers will see two styles side by side.

Check formatting with awkward values

Test your formats with the values most likely to break them: zero, a negative number, a very large number, a tiny rate such as 0.02%, a missing value and a long label. A rate that prints as "0.0%" may look like zero although events happened, so show more decimals or the counts for rare events. Check exported files too. A spreadsheet program may convert codes into numbers or dates when it opens a CSV file, for example by dropping leading zeros from an identifier. Open one export the way your readers will, and compare a few values with the source.

Never format a value by turning it into text inside your data pipeline and then calculating with it. Keep numbers as numbers until the final display step.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. Which date is least ambiguous for an international audience?

    ISO 8601 puts year, month and day in a fixed order.
  2. 2. Rounded shares add to 99%. What should you do?

    Editing a value would make it wrong. Explain that rounding causes the gap.
  3. 3. A table column mixes values in thousands and millions. What is the best fix?

    One declared scale prevents readers from comparing different units by mistake.

Summary

  • Show only the precision that helps the decision.
  • Use one scale per column and name units and currencies clearly.
  • Write dates unambiguously and define periods and time zones.
  • Keep formatting in one place, calculate before rounding and use decimal arithmetic for money.
  • Label things in your reader's language.

Next: Dashboard Basics

Votre progression est enregistrée dans ce navigateur. Aucun compte nécessaire.