Creating a Series Object
Let’s create a Series from a Python list and dictionary objects.
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.
Press + to interact
import pandas as pdl = range(1, 10)s = pd.Series(l)print(s)print("------------------")x=3print("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 ...