Python Practice › Pandas Programs › Program 9
Dictionary to Series
Write a pandas program to convert a dictionary to a Series.
Input
{"name": "Virat", "sport": "cricket", "age": 32}Output
name Virat sport cricket age 32 dtype: object
Approach
- Keys become the index.
Solution
import pandas as pdprint(pd.Series({"name": "Virat", "sport": "cricket", "age": 32}))Output
name Virat sport cricket age 32 dtype: object
Learn the concept
New to this topic? Read the lesson, then come back.