O'Reilly logo

Practical Time Series Analysis by Dr. PKS Prakash, Dr. Avishek Pal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Maps

Python supports hashmaps or associative arrays. Every element in a hashmap is associated with a definition or key. Dict is the basic hashmap implementation in Python. The elements in a dict are called values, which are mapped to references known as keys. A dict can be instantiated from an iterable of key-value pairs. This iterable can be a list, tuple, or an iterator, which we will discuss in one of the upcoming sections. The following code snippet shows multiple ways to create a dict:

mydict = dict([(0,1), (1,2), (2,3), (3,4), (4,5)])mydict = dict([[0,1], [1,2], [2,3], [3,4], [4,5]])mydict = {0:1, 1:2, 2:3, 3:4, 4:5}

Elements from a dict can be retrieved by invoking the get method that takes the key as input. Another way is to use ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required