Skip to content
Justice Tech School

Create a Series

A Series is a one dimensional labeled array. Create it from a list, a dict or a scalar. Dict keys become the index.

Example
import pandas as pd
import numpy as np
a = pd.Series([3, 5, 7])
b = pd.Series({'x': 1, 'y': 2})
c = pd.Series(4, index=['p', 'q'])
print(a.tolist())
print(b)
print(c)

Result

[3, 5, 7]
x    1
y    2
dtype: int64
p    4
q    4
dtype: int64

Exercise

Create a Series from a list.

pd.([1, 2, 3])

Quiz Test

What do dict keys become?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.