Search⌘ K
AI Features

Add the Values of a Pandas Series

Explore how to add values in a pandas Series by understanding label-based alignment and broadcasting differences from Python lists and NumPy arrays. Learn how pandas handles unmatched labels by inserting NaN and how operations on Series depend on index matching. This lesson helps you avoid common pitfalls in pandas addition.

We'll cover the following...

Try it yourself

Try executing the code below to see the result.

Python 3.8
import pandas as pd
grades = pd.Series([61, 82, 57])
bonuses = pd.Series([10, 5, 10, 10])
out = grades + bonuses
print(out)

Explanation

The pandas.Series and numpy.ndarray are different from Python lists. The + operator included on Python lists does concatenation:

 ...