PandasCore· 25 min read

The Pandas Series

A Series is a single labelled column of data — like one column from a spreadsheet.

What you will learn

  • Create a Series
  • Use labels (the index) to look up values
  • See how a Series differs from a list

One labelled column

Pandas (a free Python library for working with tables of data — think of it as a programmable spreadsheet) is the most important tool in data science — it is how you load, clean and explore data. Its two building blocks are the Series (one column) and the DataFrame (a whole table). We start with the Series.

A Series is a list of values plus a label for each value. Those labels are called the index. Think of one column in a spreadsheet, where each cell also has a name.

A Series: values with a labelled index
import pandas as pd

sales = pd.Series([250, 300, 175],
                  index=['Mon', 'Tue', 'Wed'])
print(sales)

Note: Output: Mon 250 Tue 300 Wed 175 dtype: int64 Each number has a label on its left. dtype: int64 means the values are whole numbers.

Look things up by their label

Because each value has a label, you can grab it by name — much friendlier than remembering a position number.

Access by label, and reuse the summary functions
print('Tuesday:', sales['Tue'])    # look up by label
print('average:', sales.mean())    # a Series has the maths functions too
print('best   :', sales.max())

Note: Output: Tuesday: 300 average: 241.66666666666666 best : 300 We asked for Tuesday (300), the average of the three days (about 241.7), and the highest day (300, which was Tuesday). A Series keeps all the array maths.

Keep only the values you want

Just like a NumPy array, you can give a Series a True/False condition in the brackets and it keeps only the rows where the condition is True. This is the exact trick you will use to filter whole tables later.

Filter a Series with a condition
print(sales[sales > 200])      # keep only days that sold over 200

Note: Output: Mon 250 Tue 300 dtype: int64 Wednesday (175) was below 200, so it was dropped. The labels travel with their values, so we still see which days survived.

Python listPandas Series
Access byPosition only (x[0])Label or position
Has labels?NoYes (the index)
Built-in mean/max?NoYes
It is reallyA simple sequenceA NumPy array + labels

Tip: A Series is basically a NumPy array with labels bolted on — so it keeps all the fast maths (.mean(), .max()) and adds friendly look-up by name.

Q. What is the “index” of a Pandas Series?

Answer: The index is the set of labels (like Mon, Tue, Wed) that lets you look values up by name instead of position.

✍️ Practice

  1. Create a Series of three friends’ ages with their names as the index.
  2. Print one friend’s age by their name, then print the average age.

🏠 Homework

  1. Make a Series of your weekly spending (one value per day, days as the index). Print the total for the week and your biggest spending day.
Want to learn this with a mentor?

CodingClave runs guided, project-based training (28-day, 45-day & 6-month batches).

Explore Training →