Pandas Tutorial · Pandas Tutorial

Pandas Series

Learn all about Pandas Series in this comprehensive tutorial.

5 min read intermediate
  • A Pandas Series is like a column in a table.
  • If nothing else is specified, the values are labeled with their index number.
  • With the index argument, you can name your own labels.
  • You can also use a key/value object, like a dictionary, when creating a Series.
  • Data sets in Pandas are usually multi-dimensional tables, called DataFrames.

What is a Series?

A Pandas Series is like a column in a table.

It is a one-dimensional array holding data of any type.

python

Labels

If nothing else is specified, the values are labeled with their index number. First value has index 0, second value has index 1 etc.

This label can be used to access a specified value.

python

Create Labels

With the index argument, you can name your own labels.

python

When you have created labels, you can access an item by referring to the label.

python

Key/Value Objects as Series

You can also use a key/value object, like a dictionary, when creating a Series.

python
Note: Note: The keys of the dictionary become the labels.

To select only some of the items in the dictionary, use the index argument and specify only the items you want to include in the Series.

python

DataFrames

Data sets in Pandas are usually multi-dimensional tables, called DataFrames.

Series is like a column, a DataFrame is the whole table.

python

You will learn about DataFrames in the next chapter.

Module quiz

2 questions
1

Which of the following is true about Pandas Series?

2

What is the most common pitfall when working with Pandas Series?

Answer all questions to submit.