Chapter 4

Cruising Massive Data with Dictionaries

IN THIS CHAPTER

Bullet Why use data dictionaries?

Bullet Creating a data dictionary

Bullet Looping through a dictionary

Bullet Data dictionary methods

Data dictionaries, also called associative arrays in some languages, are kind of like lists, which we discuss in Chapter 3. But instead of each item in the list being identified by its position in the list, each item is uniquely identified by a key. You can define the key, which can be a string or a number, yourself. All that matters is that it be unique to each item in the dictionary.

To understand why uniqueness matters, think about phone numbers, email addresses, and Social Security numbers. If two or more people had the same phone number, then whenever someone called that number, all those people would get the call. If two or more people had the same email address, then all those people would get the same email messages. If two or more people had the same Social Security number, and one of those people was a million dollars behind in their taxes, you better hope you can convince the tax folks you’re not the ...

Get Python All-in-One For Dummies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.