In this python pandas program, we will convert a dictionary to a Pandas series.
Steps to solve the program
- Import pandas library as pd.
- Create a dictionary.
- Now convert that dictionary to a series using pd.Series().
- Print the output.
import pandas as pd
D = {'name':'Virat','sport':'cricket','age':32}
result = pd.Series(D)
print(result)
Output :
name Virat
sport cricket
age 32
dtype: object