Last Updated : 24 Dec, 2018
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages.
Pandasis 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 : listExample #1:
Use
Index.tolist()
function to convert the index into a list.
Python3
# 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.
Python3
# convert the index into a list
idx.tolist()
Output : Example #2:
Use
Index.tolist()
function to convert the index into a python list.
Python3
# 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.
Python3
# convert the index into a list
idx.tolist()
Output :
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4