Search⌘ K

Creating a Series Object

Explore creating Pandas Series objects from Python lists and dictionaries. Learn how to work with default integer indexes and custom string indexes, and how to access Series elements by their index values. This lesson provides foundational skills for manipulating Series in data analysis.

Create a Series from a list without an index

First, let’s create a Series from the Python list below. As you can see, we haven’t specified any index, so by default it starts at zero.

Python 3.5
import pandas as pd
l = range(1, 10)
s = pd.Series(l)
print(s)
print("------------------")
x=3
print("the index {} -> value is {}".format(x, s[x]))

A Series is created from a Python list on line 4. It’s a Series with nine values from 1 to 9, created by range(1, 9).

In the output of print(s), we can see two columns. The first column is the index number and the ...