Pandas resample重采样及freq用法

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)

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值