We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Series

A Series: in Pandas is a one-dimensional labeled array (like a single column from a table)

If we had a spreadsheet of player data from an RPG, where each row represented a player, and each column represented some attribute about the player, we could take any one of those columns as a Pandas Series. For example, a column representing each player's gold_earned:

import pandas as pd

gold_earned = pd.Series([150, 300, 75, 420])
print(gold_earned)

Prints:

0    150
1    300
2     75
3    420
dtype: int64
  • The index labels are on the left: 0, 1, 2, 3
  • The values are on the right: 150, 300, 75, 420
  • The dtype (data type) is at the bottom: int64 (64-bit integer)

You can access an individual value by its index:

print(gold_earned[0])  # 150

When to Use a Series

You may be thinking, "Isn't this just a list?" Kinda... but the Series structure has advantages, most importantly:

  • Performance: A Series uses optimized C-array operations under the hood, so it can be much faster than the same operations on a regular Python list, especially at large sizes.
  • Powerful indexing: A Series isn't just ordered – it's labeled. That means you can manipulate data using custom labels instead of just integer positions. And if you perform an operation involving multiple Series, Pandas will automatically align the data based on the index labels.

Assignment

SnackStack tracks device telemetry data, including temperature readings from smart kitchen appliances. The analytics team needs to work with individual columns of data as Series to perform calculations.

Complete the get_temperature_stats function.