Informatics Practices
A list stores three dictionaries each storing details, (old price, new price, change). Write a program to create a dataframe from it.
Python Pandas
1 Like
Answer
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)Output
old_price new_price change
0 10 12 2
1 20 18 -2
2 30 35 5
Answered By
3 Likes
Related Questions
Write a program to create a Series object that stores the table of number 5.
Write a program to create a Dataframe that stores two columns, which store the Series objects of the previous two questions (12 and 13).
Write a program to create a Dataframe storing salesmen details (name, zone, sales) of five salesmen.
Four dictionaries store the details of four employees-of-the-month as (empno, name). Write a program to create a dataframe from these.