KnowledgeBoat Logo

Informatics Practices

Write a Python program to create the following DataFrame using a list of dictionaries.

NoProductPrice
0Laptop60000
1Desktop45000
2Monitor15000
3Tablet30000

Python Pandas

1 Like

Answer

import pandas as pd 
d1 = {'Product': 'Laptop', 'Price': 60000} 
d2 = {'Product': 'Desktop', 'Price': 45000} 
d3 = {'Product': 'Monitor', 'Price': 15000} 
d4 = {'Product': 'Tablet', 'Price': 30000} 
data = [d1, d2, d3, d4] 
df = pd.DataFrame(data) 
print(df)

Output

   Product  Price
0   Laptop  60000
1  Desktop  45000
2  Monitor  15000
3   Tablet  30000

Answered By

2 Likes


Related Questions