Convert a Pandas series to a list and print its type

In this python pandas program, we will convert a Pandas series to a list and print its type.

Steps to solve the program
  1. Import pandas library as pd.
  2. Create a pandas series using pd.Series() and print it.
  3. Now, convert the series to a list using tolist().
  4. 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
<class 'pandas.core.series.Series'>
Convert Pandas Series to Python list
[15, 43, 88, 23]
<class 'list'>
				
			

create and display a one-dimensional array-like object containing an array of data

add two series

Leave a Comment