The Series
A column with labels attached, and the labels travel with the data.
A labelled column
A Series is one column of values plus an index. The index is not decoration: it is how values line up when two Series meet.
import pandas as pd
scores = pd.Series([92, 88, 79], index=["Ada", "Grace", "Alan"])
print(scores)
print(scores["Grace"])
Everything numpy did, a Series does too
Masks, arithmetic and aggregation all carry over. What is added is that the labels survive the operation.
import pandas as pd
scores = pd.Series([92, 88, 79], index=["Ada", "Grace", "Alan"])
print(scores.mean())
print(scores[scores > 85])
Exercise
Try It YourselfWrite top_scorer(scores) that takes a Series of scores indexed by name and returns the name of the highest scorer.
Press Run to see output