I have a data frame like this:
id Date Volume Price Values(Volume*Price)
56033738624803469 20170111 1 943339 943339
56033738624803469 20170111 10 919410 9194100
56033738624803469 20170112 1 919410 919410
56033738624803469 20170112 5 954999 4774955
4659957480182399 20170207 1 1000000 1000000
4659957480182399 20170208 5 1000000 5000000
4659957480182399 20170208 40 1000000 40000000
I want to compute and plot the following computation for the first 100 days for each ID:
compute average values per day over the first 100 days Plot this for all of Ids Afterwards, the plot should like this: Desired plot (https://i.stack.imgur.com/2cozR.png)
This is what I've done so far:
df2 = df.groupby(['Id', 'Date']).sum()
The result is :
Index Volume Price Values
Id Date
1745829084228393 20170207 1 1000 1000000.0 1.000000e+09
20170208 5151 999000 101000000.0 9.990000e+11
20170403 1 12 1000100.0 1.200120e+07
20170408 1 12 1000000.0 1.200000e+07
20170417 1 500 1000000.0 5.000000e+08
20170423 3 14500 2000000.0 1.450000e+10
20170507 10 35000 4000000.0 3.500000e+10
20170510 21 49051 6000000.0 4.905100e+10
20170529 1 4 1000000.0 4.000000e+06
2888358730233310 20170212 820 2000000 40000000.0 2.000000e+12
2929948497881810 20170207 1830 1500000 60000000.0 1.500000e+12
20170208 903 700000 42000000.0 7.000000e+11
20170212 1176 800000 48000000.0 8.000000e+11
3715246194918044 20150509 66 1008 11000000.0 1.008000e+09
Now I want to calculate sum of first , second ,... of each ID for Values, for example:
Date_Order Sum_Values(= summation first date of each id )
first_Date (1.000000e+09 + 2.000000e+12 + 1.500000e+12 + 1.008000e+09)
second_Date (9.990000e+11 + 7.000000e+11)
ids are important i want summation of first day of values of each id(ids are different and may start on different days)