Skip to Content
Pandas for Everyone: Python Data Analysis, First Edition
book

Pandas for Everyone: Python Data Analysis, First Edition

by Daniel Y. Chen
December 2017
Beginner to intermediate
410 pages
12h 45m
English
Addison-Wesley Professional
Content preview from Pandas for Everyone: Python Data Analysis, First Edition

K. Dictionaries

Python dictionaries (dict) are efficient ways of storing information. Just as an actual dictionary stores a word and its corresponding definition, so a Python dict stores some key and a corresponding value. Using dictionaries can make your code more readable because a label is assigned to each value in the dictionary. Contrast this with list objects, which are unlabeled. Dictionaries are created by using a set of curly brackets, {}.

my_dict = {} print(my_dict)

{}

print(type(my_dict))

<class 'dict'>

When we have a dict, we can add values to it by using square brackets, []. We put the key inside these square brackets. Usually, it is some string, but it can actually be any immutable type (e.g., a Python tuple, which is the immutable ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Pandas for Everyone: Python Data Analysis, 2nd Edition

Pandas for Everyone: Python Data Analysis, 2nd Edition

Daniel Y. Chen

Publisher Resources

ISBN: 9780134547046Purchase book