admin管理员组

文章数量:1658581

DataFrame.resample(rule, how=None, axis=0, fill_method=None, closed=None, label=None, convention='start',kind=None, loffset=None, limit=None, base=0)

参数	说明
freq	表示重采样频率,例如‘M’、‘5min’,Second(15)
how=‘mean’	用于产生聚合值的函数名或数组函数,例如‘mean’、‘ohlc’、np.max等,默认是‘mean’,其他常用的值由:‘first’、‘last’、‘median’、‘max’、‘min’
axis=0	默认是纵轴,横轴设置axis=1
fill_method = None	升采样时如何插值,比如‘ffill’、‘bfill’等
closed = ‘right’	在降采样时,各时间段的哪一段是闭合的,‘right’或‘left’,默认‘right’
label= ‘right’	在降采样时,如何设置聚合值的标签,例如,9:30-9:35会被标记成9:30还是9:35,默认9:35
loffset = None	面元标签的时间校正值,比如‘-1s’或Second(-1)用于将聚合标签调早1秒
limit=None	在向前或向后填充时,允许填充的最大时期数
kind = None	聚合到时期(‘period’)或时间戳(‘timestamp’),默认聚合到时间序列的索引类型
convention = None	当重采样时期时,将低频率转换到高频率所采用的约定(start或end)。默认‘end’

rule 参数如下:

参数	含义
B	business day
C	custom business day (experimental)
D	calendar day
W	weekly
M	month end
BM	business month end
CBM	custom business month end
MS	month start
BMS	business month start
CBMS	custom business month start
Q	quarter end
BQ	business quarter end
QZ	quarter start
BS	business quarter start
A,Y	year end frequency
BA,BY	business year end
AS,YS	year start
BAS,BYS	business year start
BH	business hour
H	hourly
T,min	minutely
S	secondly
L	milliseconds
M,ms	microseconds
N	nanoseconds

重采样(Resampling)指的是把时间序列的频度变为另一个频度的过程。把高频度的数据变为低频度叫做降采样(downsampling),把低频度变为高频度叫做升采样(upsampling)

降采样
各区间哪边是闭合的(参数:closed)
如何标记各聚合面元,用区间的开头还是末尾(参数:label)

本文标签: pandasresamplefreq