DataFrame.resample(freq)

作者: 喝奶茶不加奶茶 | 来源:发表于2020-08-04 17:22 被阅读0次

DataFrame.resample(freq),将数据基于时间列以 freq 作为频度对全局数据做重采样,计算出分段数据和、均值、方差等指标;下面例子中原数据的索引是 Datatime 数据格式,以月为时间单位求出各列数据的平均值。

# Resample the data based the offset,get the mean of data
# BM — bussiness month end frequency

apple_month = apple.resample("BM").mean()
apple_month.head()

M 全称 Bussiness Month,是商业月的意思,在 Pandas 中称为 DataOffset,除了月之外,还提供年、日、秒、小时、分…等作为采样单位,当然也可以自定义。


pandas中datetime相关

相关文章

网友评论

    本文标题:DataFrame.resample(freq)

    本文链接:https://www.haomeiwen.com/subject/gihwrktx.html