Pandas Series in Python | Complete Notes with Examples | CBSE Class 12 Informatics Practices (2026–27)
Class 12 · Informatics Practices
Pandas Series in Python
A Series is the first data structure provided by the Pandas library. It is used to store data in a single column along with labels called index.
You can think of a Series as an enhanced Python list where every value has an index label.
What is a Series?
A Series is a one-dimensional labeled array capable of storing data of any type such as integers, decimal numbers, strings, or Boolean values.
Why Do We Use Series?
- To store one-dimensional data.
- To organize data efficiently.
- To perform mathematical operations.
- To analyze data quickly.
- To access data using labels.
Characteristics of Series
| Property | Description |
|---|---|
| One Dimensional | Stores data in a single column. |
| Labeled | Each value has an index label. |
| Mutable | Values can be changed. |
| Heterogeneous | Can store different data types (though same type is preferred). |
| Size | Can store any number of elements. |
Structure of a Series
Index Value 0 45 1 60 2 75 3 90
The left side contains the Index, while the right side contains the actual Values.
Creating a Series
The syntax for creating a Series is:
import pandas as pd pd.Series(data)
Creating Series from a Python List
import pandas as pd marks = [85, 90, 78, 92] s = pd.Series(marks) print(s)Output
0 85 1 90 2 78 3 92 dtype: int64
Creating Series from a Tuple
import pandas as pd marks = (75, 81, 95, 67) s = pd.Series(marks) print(s)
Creating Series from NumPy ndarray
Before creating a Series from an ndarray, import the NumPy library.
import pandas as pd import numpy as np arr = np.array([10,20,30,40]) s = pd.Series(arr) print(s)
Creating Series from Dictionary
import pandas as pd
student = {
"Amit":85,
"Neha":92,
"Rohan":78
}
s = pd.Series(student)
print(s)
Output
Amit 85 Neha 92 Rohan 78 dtype:int64
The dictionary keys automatically become the index labels.
Creating Series from a Scalar Value
import pandas as pd s = pd.Series(100,index=[0,1,2,3]) print(s)Output
0 100 1 100 2 100 3 100 dtype:int64
When a scalar value is used, the index must be specified.
Creating Series with Custom Index
import pandas as pd marks=[85,90,95] s=pd.Series(marks,index=["A","B","C"]) print(s)Output
A 85 B 90 C 95 dtype:int64
Data Types in Series
| Python Data | dtype |
|---|---|
| 10 | int64 |
| 15.5 | float64 |
| "Hello" | object |
| True | bool |
The dtype Attribute
import pandas as pd s=pd.Series([10,20,30]) print(s.dtype)Output
int64
The name Attribute
import pandas as pd s=pd.Series([25,30,35],name="Age") print(s)
The name attribute assigns a name to the Series.
Advantages of Series
- Easy to create.
- Supports labels.
- Fast calculations.
- Handles missing values.
- Useful for data analysis.
- Works efficiently with DataFrames.
Real-Life Applications
| Application | Series Stores |
|---|---|
| School | Marks of Students |
| Hospital | Patient Temperature |
| Bank | Daily Transactions |
| Weather | Daily Temperature |
| Sports | Player Scores |
Common Errors
| Error | Reason |
|---|---|
| Index length mismatch | Number of indexes is different from values. |
| NameError | Pandas library not imported. |
| ModuleNotFoundError | Pandas package not installed. |
Quick Revision
| Concept | Remember |
|---|---|
| Series | One-dimensional data structure |
| Index | Label of each value |
| List | Can create Series |
| Tuple | Can create Series |
| Dictionary | Keys become Index |
| Scalar | Requires Index |
| Alias | pd |
CBSE Exam Tips
- Remember all five methods of creating a Series.
- Dictionary keys become the index automatically.
- Scalar values require an explicit index.
- Know the difference between List and Dictionary-based Series.
- Be able to identify the output of Series programs.
Summary
A Series is a one-dimensional labeled data structure in Pandas. It can be created from a list, tuple, NumPy ndarray, dictionary, or scalar value. Each element has an associated index, making data access and manipulation simple and efficient. Series serves as the foundation for working with DataFrames and performing data analysis in Python.