use functions to resample python

Solutions on MaxInterview for use functions to resample python by the best coders in the world

showing results for - "use functions to resample python"
Leni
07 Sep 2018
1#Resample to monthly
2df.resample('M').asfreq()
Dot
22 May 2016
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)