Pandas Series.tolist() Function

Minahil Noor Jan 30, 2023
  1. Syntax of pandas.Series.tolist():
  2. Example Codes: Series.tolist() Method to Convert a Series to List
  3. Example Codes: Series.tolist() Method to Convert a String Type Series to List
Pandas Series.tolist() Function

Python Pandas Series.tolist() function converts a series to list data type.

Syntax of pandas.Series.tolist():

Series.tolist()

Parameters

It has no parameters.

Return

It returns a list of the values of the series.

Example Codes: Series.tolist() Method to Convert a Series to List

import pandas as pd

series = pd.Series([ 1, 2, 3, 4, 5.5, 6.7])
print("The Original Series is: \n")
print(series)

series1 = series.tolist()
print("The List is: \n")
print(series1)

Output:

The Original Series is: 

0    1.0
1    2.0
2    3.0
3    4.0
4    5.5
5    6.7
dtype: float64
The List is: 

[1.0, 2.0, 3.0, 4.0, 5.5, 6.7]

The function has returned a list that contains the values of the series.

Example Codes: Series.tolist() Method to Convert a String Type Series to List

import pandas as pd

series = pd.Series([ 'Rose', 'Jasmine', 'Lili', 'Tulip', 'Hibiscus'])
print("The Original Series is: \n")
print(series)

series1 = series.tolist()
print("The List is: \n")
print(series1)

Output:

The Original Series is: 

0        Rose
1     Jasmine
2        Lili
3       Tulip
4    Hibiscus
dtype: object
The List is: 

['Rose', 'Jasmine', 'Lili', 'Tulip', 'Hibiscus']

The function has returned a list that contains string type values.

Related Article - Pandas Series