Contribute Media
A thank you to everyone who makes this possible: Read More

Using List Comprehensions and Generator Expressions For Data Processing

Description

Creating one list out of another list is a very common thing to do in Python, so common that Python includes a special construct just for this purpose: list comprehensions. We'll get hands-on experience using list comprehensions, set comprehensions, and dictionary comprehensions during this tutorial. We'll also learn how and when we can slightly tweak our comprehensions to turn them into more performant generator expressions.

We will learn some tricks for figuring out which of our "for" loops can be rewritten as comprehensions and which cannot. We will focus heavily on code readability and code clarity and we'll discuss when comprehensions help readability and when they hurt.

All new skills will be acquired through practice. We'll work through many exercises both individually and as a group. All students will also receive a cheat sheet which can be used for guidance during future comprehension-writing journeys.

A laptop with Python installed is required for this workshop.

Improve this page