A price without an instrument and date cannot support a reliable return calculation. pandas stores those labels and aligns calculations by them. This lesson loads a small price table, calculates returns and checks missing or duplicated observations. It builds on NumPy and prepares for the timing checks in time-series data.
Learning objectives. By the end of this note you should be able to:
- construct a
DataFramewith a time index; - select rows and columns by label;
- detect missing values;
- compute a return column without losing alignment.
In this lesson
- A labelled table
- Compute while preserving labels
- Validate the table before modelling
- A missing price affects adjacent returns
Before you start
The full lesson, with worked examples and exercise solutions, is for members.
Read the full lessonNew to SelfMadeQuant.com? See membership options or browse the Python and Data Primer syllabus.