A Series is one column with an index: labels on the left, values on the right. Every DataFrame column is a Series.
Build Series from lists and dicts, select by label and position, and see how indexes align.
From a list
The default index is 0, 1, 2, ….
s = pd.Series([10.5, 22.0, 31.0], name="price")
print(s)
print()
print("values:", s.to_list())
print("index:", list(s.index))
print("dtype:", s.dtype)
print("name:", s.name)From a dict — labels you choose
prices = pd.Series({"A": 10.5, "B": 22.0, "C": 31.0}, name="price")
print(prices)
print()
print("product B:", prices["B"])
print("first row by position:", prices.iloc[0])prices["B"] is label lookup. prices.iloc[0] is position lookup. Mixing them up is the most common Series bug.
Alignment
Operations match on the index, not on row number.
units = pd.Series({"A": 12, "B": 7, "C": 2}, name="units")
prices = pd.Series({"B": 22.0, "A": 10.5, "C": 31.0}, name="price")
print(units * prices)A and B still multiply correctly even though the dict order differed.
A missing label becomes NaN:
stock = pd.Series({"A": 12, "B": 7})
prices = pd.Series({"A": 10.5, "B": 22.0, "C": 31.0})
print(stock * prices)Product C has a price but no stock, so that row is missing.
Useful Series methods
s = pd.Series([12, 7, 9, 4, 11, 3], name="units")
print(s.sum(), s.mean(), s.min(), s.max())
print()
print(s.describe())
print()
print("above mean:")
print(s[s > s.mean()])Boolean Series are masks
s = pd.Series([12, 7, 9, 4], index=list("ABCD"), name="units")
mask = s >= 9
print(mask)
print()
print(s[mask])You will use this pattern on DataFrame columns in the Filter chapter.
A printed Series shows dtype at the bottom. Integers are usually int64; mixed missing values often become float64.