100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Python

Series Basics

Learn the anatomy of a pandas Series — its values, index, and name — and how label-based alignment, vectorized operations, and dtype inference make it more than a plain list.

Pandas FoundationsBeginner8 min readJul 8, 2026
Analogies

Series Basics

A pandas Series is a one-dimensional, labeled array capable of holding any single data type — integers, floats, strings, booleans, datetimes, or arbitrary Python objects. Every Series has two essential parts: the values, a NumPy array (or an extension array for special dtypes) holding the actual data, and the index, a separate array of labels that identifies each entry. Unlike a plain Python list, a Series lets you look up elements by meaningful label instead of only by integer position, and it inherits NumPy's fast, vectorized arithmetic, so operations like series * 2 run without an explicit Python loop.

🏏

Cricket analogy: A pandas Series holding a batter's scores is like a scorecard column labeled by innings number, where the underlying NumPy array stores the runs and the index labels which innings each score belongs to, letting scores * 1.0 compute strike-adjusted values instantly across all innings.

Creating a Series

A Series can be constructed from a list, a NumPy array, a dictionary, or a scalar. When you pass a dictionary, the keys automatically become the index. If you don't supply an index explicitly, pandas assigns a default RangeIndex starting at 0. You can also give a Series a name, which becomes useful later when the Series is inserted into a DataFrame as a named column.

🏏

Cricket analogy: Building a Series from a dict like {'Kohli': 82, 'Rohit': 65} automatically makes the player names the index, while building it from a plain list of scores gives a default RangeIndex, and naming the Series 'innings_1_runs' makes it self-documenting later.

python
import pandas as pd

s1 = pd.Series([10, 20, 30], index=['a', 'b', 'c'], name='scores')
print(s1)
# a    10
# b    20
# c    30
# Name: scores, dtype: int64

s2 = pd.Series({'NY': 8.3, 'LA': 3.9, 'SF': 0.87})   # dict -> index is keys
print(s2['LA'])   # 3.9  (label-based lookup)

print(s1 + 5)      # vectorized: adds 5 to every element, index preserved

Index Alignment in Arithmetic

When you perform arithmetic between two Series, pandas aligns them by index label before computing, not by their raw positional order. If a label exists in one Series but not the other, the result contains NaN at that position rather than raising an error or silently dropping the row. This automatic alignment is a defining feature that distinguishes Series math from plain NumPy array math, and it means the order in which you constructed two Series does not matter as long as the labels line up conceptually.

🏏

Cricket analogy: Adding a Series of Kohli's runs indexed by match_id to a Series of Rohit's runs indexed by match_id aligns them match-by-match, producing NaN for any match one player didn't play, regardless of which player's data was constructed first.

python
import pandas as pd

revenue = pd.Series({'Jan': 100, 'Feb': 150, 'Mar': 120})
costs   = pd.Series({'Feb': 90, 'Mar': 80, 'Apr': 60})

profit = revenue - costs
print(profit)
# Apr      NaN   (only in costs)
# Feb     60.0
# Jan      NaN   (only in revenue)
# Mar     40.0
# dtype: float64

Think of a Series as a hybrid of a Python dict and a NumPy array: like a dict, it supports fast label-based lookup; like an array, it supports vectorized math, broadcasting, and slicing — and both interfaces work on the same object simultaneously.

Because arithmetic between misaligned Series introduces NaN wherever labels don't match on both sides, forgetting to check for NaN afterward (e.g. with .isna().sum()) can silently propagate missing values into later calculations.

  • A Series has two core components: values (a NumPy/extension array) and index (the labels).
  • Constructing a Series from a dict uses the dict's keys as the index automatically.
  • Series support both label-based lookup (like a dict) and vectorized arithmetic (like a NumPy array).
  • Arithmetic between two Series aligns by index label, introducing NaN for labels present in only one Series.
  • A Series can have a name, which becomes the column name when inserted into a DataFrame.
  • Without an explicit index, pandas assigns a default RangeIndex starting from 0.

Practice what you learned

Was this page helpful?

Topics covered

#Python#PandasNumPyStudyNotes#DataScience#SeriesBasics#Series#Creating#Index#Alignment#StudyNotes#SkillVeris