Module 1: Getting started · Lesson 1.3 · about 15 min
Series: one column of data
A Series is one column with an index: make one, do maths on the whole column at once, use summary methods like sum, mean and value_counts, and see how missing values behave.
Module 1 · about 15 minutes · uses Lesson 1.2. You’ll be able to create a Series, do column maths, and summarise it.
In everyday terms: a column in a spreadsheet where the row numbers can be names (store IDs, dates). Typing ”× 2” once doubles every cell, with no formula to drag down.
1. A labelled column
A Series is one column of values plus an index of labels. Each column of a DataFrame is a Series.
The left column is the index (labels), the right the values. Below, pandas notes the dtype: int64 means whole numbers.
2. Whole-column maths
Operations apply to every value at once. No loops.
The last line is filtering: a True/False Series inside the brackets keeps the True rows. You’ll use it constantly (Lesson 2.3).
3. Summaries
None became NaN (“not a number”), pandas’ mark for missing, and the whole Series turned into decimals (float64), because NaN is a float. Summaries skip NaN: the mean is over 4 days, not 5.
For text, value_counts() counts each value:
- values
- The data, all of one type.
- index
- The labels of the rows (0, 1, 2... by default).
- s * 2, s + t
- Whole-column maths; two Series line up by index label, not by position.
- Physical meaning
- The index is how pandas knows which value belongs to which thing. Adding two Series matches labels like matching name tags, so a value never lands on the wrong store even if the order differs.
“Adding two columns adds them row by row in order.” pandas adds them by index label. If one Series has S01, S02 and the other S02, S03, you get NaN for S01 and S03. Check the labels when results look half empty.
Watch it happen, one step at a time:
| index | value |
|---|---|
| S01 | 120 |
| S02 | 95 |
| WEB | 140 |
s * 1.1 multiplies every value: 132, 104.5, 154.s.sum() → 355; s.mean() → 118.33.| index | s + t |
|---|---|
| S01 | NaN |
| S02 | 100 |
| WEB | 150 |
4. Your turn
How it works
Principle: a Series is a NumPy array of one type plus an index. Maths runs on the whole array in compiled code (vectorised), which is why s * 2 on a million values takes milliseconds.
Alignment: when you combine two Series, pandas matches labels, not positions. Index labels missing on one side give NaN:
5. Practice
- What dtype is
pd.Series([1, 2, None]), and why? - How do you count the missing values in
s? s = pd.Series([5, 10, 15]). What doess[s >= 10].sum()give?
Answers
float64: missing values are NaN, which is a float, so the whole column becomes floats.s.isna().sum()(True counts as 1).-
New words: Series, index, dtype, vectorised, NaN, boolean mask, alignment.
- A Series = values + index labels.
- Arithmetic applies to every value at once.
- Two Series combine by matching labels, not positions.
- sum, mean, min, max, count and describe summarise a Series.
Check yourself
Sources
- pandas documentation, User Guide: Intro to data structures https://pandas.pydata.org/docs/user_guide/dsintro.html
- McKinney, W. (2022), Python for Data Analysis, 3rd edition, O'Reilly (open access) https://wesmckinney.com/book/
Your ticks stay in this browser. Save them as a file on the course home.
Updated 2026-11-22. All datasets are made up. Python runs in your browser (the first run downloads it once, about 20 MB); nothing you type is sent anywhere.