python - Pandas rolling mean not working -


i trying calculate rolling mean on df below. reason, won't calculate. have used same code snippet else in code , there seems working fine.

i using python 2.7 , pandas 0.20.2

df.fillna(0, inplace=true) print 'df head \n', df.head(50) df1 = pd.dataframe({'rolling_mean':df.groupby(['personid','date'])['count_of_metric'].rolling(15,1).mean()}) print 'df1 head \n',df1.head(50) 

here getting. can help?

df head           personid        date  count_of_metric  to_drop 354    0-orphan22  2012-11-08              0.0        0 531    0-orphan22  2012-11-09              2.0        0 177    0-orphan22  2012-11-10              0.0        0 355    0-orphan22  2012-11-11              0.0        0 532    0-orphan22  2012-11-12              0.0        0 0      0-orphan22  2012-11-13              1.0        0 356    0-orphan22  2012-11-14              0.0        0 533    0-orphan22  2012-11-15              0.0        0 1      0-orphan22  2012-11-16              0.0        0 178    0-orphan22  2012-11-17              0.0        0 534    0-orphan22  2012-11-18              0.0        0 2      0-orphan22  2012-11-19              0.0        0 179    0-orphan22  2012-11-20              2.0        0 357    0-orphan22  2012-11-21              0.0        0 3      0-orphan22  2012-11-22              0.0        0 180    0-orphan22  2012-11-23              0.0        0 358    0-orphan22  2012-11-24              0.0        0 535    0-orphan22  2012-11-25              0.0        0 181    0-orphan22  2012-11-26              0.0        0 359    0-orphan22  2012-11-27              0.0        0 536    0-orphan22  2012-11-28              0.0        0 4      0-orphan22  2012-11-29              0.0        0 360    0-orphan22  2012-11-30              0.0        0 537    0-orphan22  2012-12-01              0.0        0 182    0-orphan22  2012-12-03              0.0        0 361    0-orphan22  2012-12-04              0.0        0 5      0-orphan22  2012-12-05              0.0        0 183    0-orphan22  2012-12-06              0.0        0 362    0-orphan22  2012-12-07              0.0        0 538    0-orphan22  2012-12-08              0.0        0 363    0-orphan22  2012-12-10              0.0        0 539    0-orphan22  2012-12-11              0.0        0 6      0-orphan22  2012-12-12              0.0        0 576         10-22  2012-11-12              0.0        0 50          10-22  2012-11-13              0.0        0   df1 head                               rolling_mean personid     date                         0-orphan22   2012-11-08 354           0.0              2012-11-09 531           2.0              2012-11-10 177           0.0              2012-11-11 355           0.0              2012-11-12 532           0.0              2012-11-13 0             1.0              2012-11-14 356           0.0              2012-11-15 533           0.0              2012-11-16 1             0.0              2012-11-17 178           0.0              2012-11-18 534           0.0              2012-11-19 2             0.0              2012-11-20 179           2.0              2012-11-21 357           0.0              2012-11-22 3             0.0              2012-11-23 180           0.0              2012-11-24 358           0.0              2012-11-25 535           0.0              2012-11-26 181           0.0              2012-11-27 359           0.0              2012-11-28 536           0.0              2012-11-29 4             0.0              2012-11-30 360           0.0              2012-12-01 537           0.0              2012-12-03 182           0.0              2012-12-04 361           0.0              2012-12-05 5             0.0              2012-12-06 183           0.0              2012-12-07 362           0.0              2012-12-08 538           0.0              2012-12-10 363           0.0              2012-12-11 539           0.0              2012-12-12 6             0.0 10-22        2012-11-12 576           0.0              2012-11-13 50            0.0 

i typing here because won't allow me post unless add more details. finds there more code details. please ignore line.


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -