++++
Data Science
May 2026×Notebook lesson

Notebook converted from Jupyter for blog publishing.

00-Series

Driptanil Datta
Driptanil DattaSoftware Developer

Series

The first main data type we will learn about for pandas is the Series data type. Let's import Pandas and explore the Series object.

A Series is very similar to a NumPy array (in fact it is built on top of the NumPy array object). What differentiates the NumPy array from a Series, is that a Series can have axis labels, meaning it can be indexed by a label, instead of just a number location. It also doesn't need to hold numeric data, it can hold any arbitrary Python Object.

Let's explore this concept through some examples:

Imports

import numpy as np
import pandas as pd

Creating a Series from Python Objects

help(pd.Series)
STDOUT
MORE
Help on class Series in module pandas.core.series:

class Series(pandas.core.base.IndexOpsMixin, pandas.core.generic.NDFrame)
 |  One-dimensional ndarray with axis labels (including time series).
 |  

Index and Data Lists

We can create a Series from Python lists (also from NumPy arrays)

myindex = ['USA','Canada','Mexico']
mydata = [1776,1867,1821]
myser = pd.Series(data=mydata)
myser
RESULT
0    1776
1    1867
2    1821
dtype: int64
pd.Series(data=mydata,index=myindex)
RESULT
USA       1776
Canada    1867
Mexico    1821
dtype: int64
ran_data = np.random.randint(0,100,4)
ran_data
RESULT
array([39, 35, 37, 23])
names = ['Andrew','Bobo','Claire','David']
ages = pd.Series(ran_data,names)
ages
RESULT
Andrew    39
Bobo      35
Claire    37
David     23
dtype: int32

From a Dictionary

ages = {'Sammy':5,'Frank':10,'Spike':7}
ages
RESULT
{'Frank': 10, 'Sammy': 5, 'Spike': 7}
pd.Series(ages)
RESULT
Sammy     5
Frank    10
Spike     7
dtype: int64

Key Ideas of a Series

Named Index

# Imaginary Sales Data for 1st and 2nd Quarters for Global Company
q1 = {'Japan': 80, 'China': 450, 'India': 200, 'USA': 250}
q2 = {'Brazil': 100,'China': 500, 'India': 210,'USA': 260}
# Convert into Pandas Series
sales_Q1 = pd.Series(q1)
sales_Q2 = pd.Series(q2)
sales_Q1
RESULT
Japan     80
China    450
India    200
USA      250
dtype: int64
# Call values based on Named Index
sales_Q1['Japan']
RESULT
80
# Integer Based Location information also retained!
sales_Q1[0]
RESULT
80

Be careful with potential errors!

# Wrong Name
# sales_Q1['France']
# Accidental Extra Space
# sales_Q1['USA ']
# Capitalization Mistake
# sales_Q1['usa']

Operations

# Grab just the index keys
sales_Q1.keys()
RESULT
Index(['Japan', 'China', 'India', 'USA'], dtype='object')
# Can Perform Operations Broadcasted across entire Series
sales_Q1 * 2
RESULT
Japan    160
China    900
India    400
USA      500
dtype: int64
sales_Q2 / 100
RESULT
Brazil    1.0
China     5.0
India     2.1
USA       2.6
dtype: float64

Between Series

# Notice how Pandas informs you of mismatch with NaN
sales_Q1 + sales_Q2
RESULT
MORE
Brazil      NaN
China     950.0
India     410.0
Japan       NaN
USA       510.0
# You can fill these with any value you want
sales_Q1.add(sales_Q2,fill_value=0)
RESULT
MORE
Brazil    100.0
China     950.0
India     410.0
Japan      80.0
USA       510.0

That is all we need to know about Series, up next, DataFrames!

Drip

Driptanil Datta

Software Developer

Building full-stack systems, one commit at a time. This blog is a centralized learning archive for developers.

Legal Notes
Disclaimer

The content provided on this blog is for educational and informational purposes only. While I strive for accuracy, all information is provided "as is" without any warranties of completeness, reliability, or accuracy. Any action you take upon the information found on this website is strictly at your own risk.

Copyright & IP

Certain technical content, interview questions, and datasets are curated from external educational sources to provide a centralized learning resource. Respect for original authorship is maintained; no copyright infringement is intended. All trademarks, logos, and brand names are the property of their respective owners.

System Operational

© 2026 Driptanil Datta. All rights reserved.