🎓 A1Learner
🔍
0 of 50 lessons completed

Series: One Column

A Series is one column of data. A Series holds values in order, with one value per row.

A Series of numbers

This list holds three numbers. The Series keeps them in the same order.

import pandas as pd

units = pd.Series([2, 1, 3])
print(units)

A Series of words

A Series can hold words instead of numbers. Each word sits on its own row.

import pandas as pd

products = pd.Series(["Tea", "Coffee", "Mug"])
print(products)

Example

import pandas as pd

units = pd.Series([2, 1, 3, 2, 5, 1, 4, 2, 1, 3, 2, 2])
print(units)

Key points

  • Build a Series from a list with pd.Series.
  • A Series holds values of one kind, like numbers or words.
  • A DataFrame is a set of Series side by side.
  • Print a Series to see its values and their row numbers.
  • The row numbers start at 0, just like in a DataFrame.

In this example, a list of twelve numbers builds a Series. The list holds the units sold in twelve orders. The print shows each value with its row number, and the last line names the kind of value.

Note

A Series is one column, so it has no column name of its own here.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Python Playground

Exercise

What is a Series?