In this python pandas program, we will convert a dictionary into DataFrame using pandas library.
Steps to solve the program
- Import pandas library as pd.
- Create a dictionary.
- Now convert that dictionary to DataFrame using pd.DataFrame().
- Print the output.
import pandas as pd
dictionary = {'marks1':[34,20,32,30],'marks2':[36,22,10,44]}
df = pd.DataFrame(dictionary)
print(df)
Output :
0 marks1 marks2
0 34 36
1 20 22
2 32 10
3 30 44