CBSE Class 12 Informatics Practices
Question 167 of 167
Python Pandas — I — Question 21
Back to all questions 21
Question A list stores three dictionaries each storing details, (old price, new price, change). Write a program to create a dataframe from it.
import pandas as pd
prices = [{'old_price': 10, 'new_price': 12, 'change': 2},
{'old_price': 20, 'new_price': 18, 'change': -2},
{'old_price': 30, 'new_price': 35, 'change': 5}]
df = pd.DataFrame(prices)
print(df) old_price new_price change
0 10 12 2
1 20 18 -2
2 30 35 5