Creating a pandas series

There are many ways to create pandas series objects. The following are some of the most common ways:

  • Creation from a list
  • Creation from a dictionary
  • Creation from a NumPy array
  • Creation from an external data source, such as a file

Lets now learn how to create series from lists, dictionaries, and a NumPy array. First, let's define the data and index them as lists. Let's create a list of values and name it temperature, and another list of values named days. To create a series from the data, all you have to do is use the pd.Series(temperature, index=days) constructor:

When we run the code, we see that each value is ...

Get Become a Python Data Analyst now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.