sum rows indexed by consecutive days
I need to do some calculations based on the sum of measures made on
consecutive days. So for example:
rng = pd.date_range('1/3/2000', periods=8)
rng = rng[:4].append(rng[5:])
ts = Series(randn(7).astype('int'), index=rng)
ts
Out[1]:
2000-01-03 0
2000-01-04 0
2000-01-05 0
2000-01-06 -1
2000-01-08 0
2000-01-09 -2
2000-01-10 -1
dtype: int64
How could I sum consecutive day values here, so I would get something like
this?
Out[2]:
2000-01-03 -1
2000-01-04 -1
2000-01-05 -1
2000-01-06 -1
2000-01-08 -3
2000-01-09 -3
2000-01-10 -3
dtype: int64
[Edit] Similar problem solved in R
No comments:
Post a Comment