w3resource logo

:

Python Exercises

Python Pandas: Convert a Panda module Series to Python list and it’s type

Python Pandas: Date Series Exercise-2 with Solution

Write a Python program to convert a Panda module Series to Python list and it’s type.

Sample Solution :-

Python Code :

import pandas as pd
ds = pd.Series([2, 4, 6, 8, 10])
print("Pandas Series and type")
print(ds)
print(type(ds))
print("Convert Pandas Series to Python list")
print(ds.tolist())
print(type(ds.tolist()))

Sample Output:

Pandas Series and type                                                 
0     2                                                                
1     4                                                                
2     6                                                                
3     8                                                                
4    10                                                                
dtype: int64                                                           
<class 'pandas.core.series.Series'>                                    
Convert Pandas Series to Python list                                   
[2, 4, 6, 8, 10]                                                       
<class 'list'>                                                      

Python Code Editor:

Improve this sample solution and post your code through Disqus