This is a bit of a hack, but it works:
import datetime import pandas as pd time_vec = [datetime.datetime(2013,9,26,17,0,0) ,datetime.datetime(2013,9,26,17,5,0) ,datetime.datetime(2013,9,26,17,8,41) ,datetime.datetime(2013,9,26,17,38,43) ,datetime.datetime(2013,9,26,17,49,55) ,datetime.datetime(2013,9,26,17,49,57)] df = pd.DataFrame([1,1,1,1,0,1],index = time_vec,columns=['value']) df['count_change']=0 df.ix[df.value!=df.value.shift(1),'count_change']=1 df.ix[0,'count_change']=0 df.resample('15min',how={'value': 'last', 'count_change': 'sum'},fill_method='ffill',label='right')
Edit:
I just realized that you can only forward the filling of the value column with intervals without data, but not the count_change column (although this does not change anything in this particular example). Workaround may be:
df.resample('15min',how={'value': 'last', 'count_change': 'sum'},label='right').fillna(value={'count_change':0}).fillna(method='ffill')