1df.resample("W").agg(['min','max','mean','std'])
2
3# resample("3T") ==> 3 minutes
4# resample("30S") ==> 30 seconds
5# resample("1H") ==> 1 hour
6# resample("D") ==> day
7# resample("W") ==> week
8# resample("M") ==> month
9# resample("Y") ==> year
10# resample("Q") ==> quarter
11# Ex. 2018-01-01 ==> 2018-03-01 , 2018-06-01 , 2018-09-01 , 2018-12-01
12#####################################
13# .mean()
14# .max()
15# .min()
16# .sum()
17......
18# .agg(['min','max',...]) specified functions are applied for every column
1In [101]: df.resample('1H').agg({'openbid': 'first',
2 'highbid': 'max',
3 'lowbid': 'min',
4 'closebid': 'last'})
5Out[101]:
6 lowbid highbid closebid openbid
7ctime
82015-09-30 23:00:00 1.11687 1.11712 1.11708 1.117
9
1#We can also use custom functions and apply them when resampling using the .apply(method_name) method
2#This is an example used in a downsampling example
3def custom_resampler(arraylike):
4 return np.sum(arraylike) + 5
5data.resample('Q').apply(custom_resampler)