Lesson 1.2

Comprehensions and iteration

A comprehension is a filter and a transform in one line. Readable when the logic is small, unreadable the moment you nest three of them.

Duration
10m
Level
Beginner
Students
30k students

Overview

A comprehension is a filter and a transform in one line. Readable when the logic is small, unreadable the moment you nest three of them.

In this lesson you will:

  • Transform and filter a sequence in one expression
  • Build dict and set comprehensions
  • Know when a plain loop is clearer

Resources

pandas documentation

The official reference for the tools used in this lesson.