Skip to content
Python for Quantitative Finance / Scientific Python and data

Tabular and Time-Indexed Data

A covariance matrix estimated on misaligned closes is not a statistics problem — it is a time-index problem that escaped into the estimator. This note treats pandas as the market-data layer: a DatetimeIndex as part of the contract, alignment before combination, resampling with an explicit aggregation rule, missing-value policy that does not invent performance, and a clean choice between simple and log returns before the frame is handed to NumPy.
Learning objectives. By the end of this note you should be able to:
  • build and validate a multi-asset price panel with a monotonic, unique DatetimeIndex;
  • align two series on timestamps and diagnose the NaNs that alignment introduces;
  • resample prices and volumes with field-appropriate aggregations;
  • compute simple and log returns, state when each is preferred, and hand a clean T×NT \times N array to numerics.

In this lesson

  1. The DatetimeIndex is part of the schema
  2. Alignment before arithmetic
  3. Resampling with a stated rule
  4. Missing values as information
  5. Simple versus log returns
  6. Point-in-time caution (boundary)

Before you start

The full lesson, with worked examples and exercise solutions, is for members.

Read the full lesson

New to SelfMadeQuant.com? See membership options or browse the Python for Quantitative Finance syllabus.