pySohila’s learning labPYTHON / FIELD GUIDE 01

Choose your next depth / OPTIONAL DEPTH

Time zones, money & measurement units

Make temporal and numeric meaning explicit before aggregation.

3h planning budget · Sohila Khaled Abbas · Reviewed 2026-11-01

Apply this to your Python data tools, PixelFed quality work, n8n integrations or BI delivery when the project needs it.

Understand the idea

A timestamp without a time zone is ambiguous until a source contract supplies its meaning. The event time and the time your process fetched the event answer different questions. Keep both when freshness affects a downstream decision.

A currency amount and an exchange rate need different precision policies. EGP minor units work well for many expense amounts, but a forex rate may require more than two decimal places. Do not truncate a rate using the ledger’s amount parser. On Windows, install the first-party tzdata package in the project environment if IANA zone data is unavailable.

What to learn

A small original example

from datetime import datetime, timezone
from zoneinfo import ZoneInfo

instant = datetime(2026, 11, 1, 12, tzinfo=timezone.utc)
local = instant.astimezone(ZoneInfo("Africa/Cairo"))
print(instant.isoformat(), local.isoformat())

Practice on your own data

Design a quote fixture contract with provider_as_of, fetched_at, rate precision, base and quote currency. Test an invalid date and stale quote.

Practice this lesson in the Python lab →

EXIT CHECK

A stale observation is not described as live; time conversion preserves the instant; amounts reconcile at the documented precision.

Prerequisites

Variables, types & missing values · Files, CSV, JSON & paths · APIs, JSON & failure policies

Sources and further reading

Track progress on this topic → · Markdown source ↗