Pandas Series — The Foundation
A Series is a single column of data with an index. Every DataFrame column is a Series. Understanding Series operations makes DataFrame work much cleaner.
What is a Pandas Series and how do you create one?
import pandas as pd
s = pd.Series([10, 20, 30, 40], name="salary")
s = pd.Series({"a": 1, "b": 2, "c": 3}) # dict → Series
s = pd.Series([1, 2, 3], index=["x","y","z"]) # custom indexA Series is a 1D labelled array — like a single Excel column with row labels. The index is what makes it different from a plain NumPy array. Every DataFrame column is a Series.
How do you access elements in a Series?
s = pd.Series([10, 20, 30], index=["a", "b", "c"])
s["a"] # 10 — by label
s[0] # 10 — by position
s.iloc[0] # 10 — explicit position
s.loc["b"] # 20 — explicit label
s[["a","c"]] # multiple: Series with a and c.loc uses labels, .iloc uses integer positions. Always prefer .loc/.iloc over plain [] to be explicit and avoid ambiguity when the index is numeric.
How do you filter a Series using boolean conditions?
s = pd.Series([15, 42, 8, 31, 27])
s[s > 20] # values greater than 20
s[(s > 10) & (s < 40)] # between 10 and 40
s.between(10, 40) # same, cleaner
s[s.isin([15, 31])] # in a list of valuesBoolean indexing is the foundation of all Pandas filtering. The & and | operators must be used (not and/or). Each condition must be wrapped in parentheses.
What are the most useful Series methods?
s = pd.Series([3, 1, 4, 1, 5, 9, 2, 6])
s.value_counts() # frequency of each value
s.unique() # unique values
s.nunique() # count of unique values
s.sort_values() # sorted
s.cumsum() # cumulative sum
s.describe() # stats summary
s.apply(lambda x: x**2) # apply functionvalue_counts() is one of the most-used methods in EDA — shows distribution of categorical columns. nunique() quickly tells you cardinality, which guides whether to encode or group a variable.
How do you handle missing values in a Series?
s = pd.Series([1, None, 3, None, 5])
s.isna() # [False, True, False, True, False]
s.notna() # opposite
s.isna().sum() # count of nulls: 2
s.fillna(0) # replace NaN with 0
s.dropna() # remove NaN rows
s.fillna(s.mean()) # fill with meanAlways check nulls before any calculation — NaN propagates silently in arithmetic. isna().sum() per column is always the first step in EDA.
EVIKA ACADEMY · PYTHON FOR DATA ANALYTICS
Want to master Python with live practice?
Join our Python for Data Analysis course — live classes in Noida and online across India.
Book Free Demo Class →