例如
dataframe.resample('M',how=np.mean) # 按照每个月求平均值
dataframe.resample('M',how=np.median) # 按照月求中位数
最新的计算方式如下:
data = df.loc[:,['total_purchase_amt','total_redeem_amt']].resample('D').apply(np.sum) # 计算dataframe名称为total_purchase_amt与total_redeem_amt两列数据按照天求和的结果
其中第一个参数的解释
B business day frequency
C custom business day frequency (experimental)
D calendar day frequency
W weekly frequency
M month end frequency
BM business month end frequency
CBM custom business month end frequency
MS month start frequency
BMS business month start frequency
CBMS custom business month start frequency
Q quarter end frequency
BQ business quarter endfrequency
QS quarter start frequency
BQS business quarter start frequency
A year end frequency
BA business year end frequency
AS year start frequency
BAS business year start frequency
BH business hour frequency
H hourly frequency
T minutely frequency
S secondly frequency
L milliseonds
U microseconds
N nanoseconds