← 30 Days of Python
Day 9 / 30Pandas

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.

1
Easy

What is a Pandas Series and how do you create one?

Python Answer
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 index
💡

A 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.

2
Easy

How do you access elements in a Series?

Python Answer
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.

3
Medium

How do you filter a Series using boolean conditions?

Python Answer
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 values
💡

Boolean indexing is the foundation of all Pandas filtering. The & and | operators must be used (not and/or). Each condition must be wrapped in parentheses.

4
Medium

What are the most useful Series methods?

Python Answer
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 function
💡

value_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.

5
Medium

How do you handle missing values in a Series?

Python Answer
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 mean
💡

Always 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 →
← PREVIOUSDay 8: NumPy Arrays — FundamentalsNEXT →Day 10: DataFrames — Core Operations
Best Data Analytics Course in Noida Delhi NCR | EVIKA ACADEMY