Q. A list stores three dictionaries each storing details, (old price, new price, change). Write a program to create a dataframe from it.
Answer =
import pandas as pd import numpy as np list = [{"old price":[10,20,30,50,40]},{"new price":[15,20,25,36,50]},{"change":[5,0,-5,-14,10]}] df = pd.DataFrame(list[0]) df["new price"] = list[1]['new price'] df["change"] = list[2]["change"] print(df)
Output :-
old price new price change
0 10 15 5
1 20 20 0
2 30 25 -5
3 50 36 -14
4 40 50 10
>
Thank u soo much dear pathwalla..I really appreciate ur work..!
ReplyDeleteGood work 👍..keep it up
Welcome 😊😊
DeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )