What Is a Pandas Series?

A Pandas Series is a one-dimensional labeled array capable of holding data of any type such as integers, floats, strings, or Python objects. Each value in a Series is associated with an index, which allows for fast and intuitive data access.

You can think of a Series as a single column of a table with row labels.

Why Use Pandas Series?

A Pandas Series is useful because it:

  • Stores labeled data

  • Supports fast indexing and slicing

  • Handles missing values (NaN) gracefully

  • Performs vectorized operations

  • Integrates seamlessly with NumPy

Creating a Pandas Series

1. Create Series from a List

Python
import pandas as pd s = pd.Series([10, 20, 30, 40]) print(s) # Output: # 0 10 # 1 20 # 2 30 # 3 40 # dtype: int64

If no index is provided, Pandas assigns a default integer index starting from 0.

2. Create Series with Custom Index

Python
import pandas as pd
s = pd.Series([100, 200, 300], index=["a", "b", "c"]) print(s) # Output: # a 100 # b 200 # c 300 # dtype: int64

Custom indices make data more meaningful and readable.

3. Create Series from a Dictionary

Python
import pandas as pd data = {"Math": 85, "Science": 90, "English": 88} s = pd.Series(data) print(s) # Output: # Math 85 # Science 90 # English 88 # dtype: int64

Dictionary keys become index labels, and values become Series values.

4. Create Series with a Scalar Value

Python
import pandas as pd s = pd.Series(5, index=["a", "b", "c"]) print(s) # Output: # a 5 # b 5 # c 5 # dtype: int64

The scalar value is repeated for each index label.

Accessing Elements in a Series

Access by Index Position

Python
import pandas as pd s = pd.Series([10, 20, 30, 40]) print(s[0]) print(s[2]) # Output: # 10 # 30

Access by Index Label

Python
import pandas as pd s = pd.Series([100, 200, 300], index=["a", "b", "c"]) print(s["b"]) # Output: # 200

Series Operations

Pandas Series supports vectorized operations, meaning operations are applied element-wise.

Python
import pandas as pd s = pd.Series([1, 2, 3, 4]) print(s + 10) # Output: # 0 11 # 1 12 # 2 13 # 3 14 # dtype: int64

Handling Missing Values

Pandas automatically handles missing data using NaN.

Python
import pandas as pd s = pd.Series([10, 20, None, 40]) print(s) # Output: # 0 10.0 # 1 20.0 # 2 NaN # 3 40.0 # dtype: float64

Useful Series Attributes

AttributeDescription
s.indexReturns index labels
s.valuesReturns underlying NumPy array
s.dtypeReturns data type
s.sizeNumber of elements
s.nameName of the Series

Difference Between Pandas Series and NumPy Array

FeaturePandas SeriesNumPy Array
Dimension1DN-dimensional
LabelsYesNo
Missing ValuesSupportedLimited
Data TypeCan be mixedHomogeneous

Key Points to Remember

  • A Series is a one-dimensional labeled array

  • Index labels make data access intuitive

  • Supports vectorized operations

  • Handles missing values efficiently

  • Forms the foundation of Pandas DataFrames