Friday, October 24, 2025
HomeLanguagesPython | Pandas Series.tolist()

Python | Pandas Series.tolist()

Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.

Pandas tolist() is used to convert a series to list. Initially the series is of type pandas.core.series.Series and applying tolist() method, it is converted to list data type.

Syntax: Series.tolist()

Return type: Converted series into List

To download the data set used in following example, click here.
In the following examples, the data frame used contains data of some NBA players. The image of data frame before any operations is attached below.

Example:
In this example, the data type of Name column is stored in a variable. After that it is converted using tolist() method and again data type is stored and printed.




# importing pandas module 
import pandas as pd 
  
# importing regex module
import re
    
# making data frame 
    
# removing null values to avoid errors 
data.dropna(inplace = True) 
  
# storing dtype before operation
dtype_before = type(data["Salary"])
  
# converting to list
salary_list = data["Salary"].tolist()
  
# storing dtype after operation
dtype_after = type(salary_list)
  
# printing dtype
print("Data type before converting = {}\nData type after converting = {}".format(dtype_before, dtype_after))
  
# displaying list
salary_list


Output:
As shown in the output image, the data type was converted from Series to List. The output of salary_list was in list format.

RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS