Module · 5 lessons

Data Structures for Data Work

The right data structure makes the access pattern cheap. Learn why a dict finds a zone instantly while a list hunts for it, why popping the front of a list is a hidden trap and a deque is not, how a heap answers top-N without sorting anything, and how to choose between them by access pattern — all measured on the real NYC taxi data.

At a glance

Level
Beginner to Intermediate
Lessons
5 lessons
Time to complete
1 week
Cost
Free forever · no sign-up

Welcome to Data Structures for Data Work, the sixth module — where your pipeline stops doing work it never needed to do. Module 5 spread the job across every core on the machine and cut the wall clock by nearly four. That is a real win, but it is also a blunt one: parallelism makes slow code finish sooner without making it less wasteful. If every trip triggers a linear scan through a list of zones to find a borough name, six processes just perform that wasteful scan six times at once. The deeper fix is to change the shape of the data so the scan never happens.

That is what a data structure buys you. A dict finds a zone by id in the same time whether it holds ten entries or ten million, because hashing jumps straight to the answer instead of looking through the candidates. A set answers “have I seen this trip before?” the same way. A deque gives a streaming buffer a genuinely constant-time front, where a plain list quietly re-copies every element on each pop(0). A heap hands you the ten busiest zones without ever sorting the other two hundred and fifty-five. Each is a different bargain between memory, insertion cost, and lookup cost, and knowing which bargain fits the access pattern is the difference between a pipeline that scales and one that merely runs.

Across five lessons you’ll measure every one of those claims on CityFlow’s real taxi data, then assemble them: the guided project builds an in-memory zone index and a top-N ranking in a single pass over a month of trips. Start with Lesson 1, where a lookup that a list takes milliseconds to perform is answered by a dict in well under a microsecond — and the gap only widens as the data grows.

Lessons in this module

Achievement

Complete all 5 lessons to finish the Data Structures for Data Work module.

Start module
Sponsor

Keep DATATWEETS free. Help fund practical data, AI, and engineering lessons for learners worldwide.

Buy Me a Coffee at ko-fi.com