import pandas as pd
While numpy arrays have an implicitly defined integer index used to access the values, the pandas
objects have an explicitly defined index associated with the values, a feature shared with the python dictionary construct. To begin our pandas
exercises, start by converting dictionaries to pandas objects.
Tasks:
d0
to a corresponding pandas object pd0
.d0 = {2:'a', 1:'b', 3:'c'}
pd0
.(Note: Newer versions of pandas
do not sort dictionary keys.)
d1, d2
(together) to a pandas object dd
.d1 = {'a': 1, 'b': 2}
d2 = {'b': 3, 'c': 4}
dd
.In pandas, indexing refers to accessing columns by their names, in a syntax reminiscent of dictionary access by keys, while slicing refers to row access like in numpy.
dd
.