How to Create a pandas Series from a List

TLDR solution

import pandas as pd

x_list = [x1, x2, x3, ...]

x_series = pd.Series(x_list)

Step-by-Step Example

Step 1: Install the pandas Package

If you don't have pandas already installed, execute the following command in your terminal:

pip install pandas

Step 2: Convert a Python List to a pandas Series

Let's say, you have the following list:

fish_list = ["salmon", "pufferfish", "shark"]

Convert it to a pandas series like this:

import pandas as pd

fish_series = pd.Series(fish_list)

print(fish_series)

The output of the code should look like this:

0        salmon
1    pufferfish
2         shark
dtype: object

That's it! You just learned how to convert a list to a pandas series.