In this python pandas program, we will convert a Pandas series to a list and print its type.
Steps to solve the program
- Import pandas library as pd.
- Create a pandas series using pd.Series() and print it.
- Now, convert the series to a list using tolist().
- To print the type use type().
import pandas as pd
df = pd.Series([15,43,88,23])
print(df)
print(type(df))
print("Convert Pandas Series to Python list")
print(df.tolist())
print(type(df.tolist()))
Output :
0 15
1 43
2 88
3 23
dtype: int64
Convert Pandas Series to Python list
[15, 43, 88, 23]