Friday, July 3, 2026
HomeLanguagesPython | Pandas Index.tolist()

Python | Pandas Index.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 Index.tolist() function return a list of the values. These are each a scalar type, which is a Python scalar (for str, int, float) or a pandas scalar (for Timestamp/Timedelta/Interval/Period).

Syntax: Index.tolist()

Parameters : None

Returns : list

Example #1: Use Index.tolist() function to convert the index into a list.




# importing pandas as pd
import pandas as pd
  
# Creating the index
idx = pd.Index(['Harry', 'Mike', 'Arther', 'Nick'],
                                  name ='Student')
  
# Print the Index
print(idx)


Output :

Let’s convert the index into a List.




# convert the index into a list
idx.tolist()


Output :

 
Example #2: Use Index.tolist() function to convert the index into a python list.




# importing pandas as pd
import pandas as pd
  
# Creating the index
idx = pd.Index(['2000-01-02', '2000-02-05', '2000-05-11',
                            '2001-02-11', '2005-11-12'])
  
# Print the Index
print(idx)


Output :

Let’s convert the index into a List.




# convert the index into a list
idx.tolist()


Output :

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32519 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6900 POSTS0 COMMENTS
Nicole Veronica
12015 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12110 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6966 POSTS0 COMMENTS