First page Back Continue Last page Overview Graphics

Using Individual Indices

A main difference to NumPy consists in usage of arbitrary indices.

>>> fruits = ['apples', 'oranges', 'cherries', 'pears']

>>> quantities = [20, 33, 52, 10]

>>> S = pd.Series(quantities, index=fruits)

>>> S

apples 20

oranges 33

cherries 52

pears 10

dtype: int64

>>>

Adding two series with the same index:

>>> S2 = pd.Series([17, 13, 31, 32], index=fruits)

>>> S + S2

apples 37

oranges 46

cherries 83

pears 42

dtype: int64

>>>