Advertisements
Advertisements
Question
Write a Python programme to create the following DataFrame using a list of dictionaries.
| Product | Price | |
| 0 | Laptop | 60000 |
| 1 | Desktop | 45000 |
| 2 | Monitor | 15000 |
| 3 | Tablet | 30000 |
Code Writing
Advertisements
Solution
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)shaalaa.com
Is there an error in this question or solution?
