pandas.resample()
http://www.cnblogs.com/hhh5460/p/5596340.html
resample与groupby的区别:
resample:在给定的时间单位内重取样
groupby:对给定的数据条目进行统计
函数原型:
DataFrame.resample(rule, how=None, axis=0, fill_method=None, closed=None, label=None, convention='start', kind=None, loffset=None, limit=None, base=0)
其中,参数how已经废弃了。
下面开始练习
import numpy as np
import pandas as pd
Start by creating a series with 9 one minute timestamps.
index = pd.date_range('1/1/2000', periods=9, freq='T')
series = pd.Series(range(9), index=index)
Downsample the series into 3 minute bins and sum the values of the timestamps falling into a bin.
series.resample('3T').sum()
To include this value close the right side of the bin interval as illustrated in the example below this one.
series.resample('3T', label='right').sum()
Downsample the series into 3 minute bins as above, but close the right side of the bin interval.
series.resample('3T', label='right', closed='right').sum()
Upsample the series into 30 second bins.
series.resample('30S').asfreq()
Upsample the series into 30 second bins and fill the NaN values using the pad method.
series.resample('30S').pad()
Upsample the series into 30 second bins and fill the NaN values using the bfill method.
series.resample('30S').bfill()
Pass a custom function via apply
def custom_resampler(array_like):
return np.sum(array_like)+5 series.resample('3T').apply(custom_resampler)
附:常见时间频率
A year
M month
W week
D day
H hour
T minute
S second
pandas.resample()的更多相关文章
- Python数据分析(三)pandas resample 重采样
下方是pandas中resample方法的定义,帮助文档http://pandas.pydata.org/pandas-docs/stable/timeseries.html#resampling中有 ...
- pandas 时间序列resample
resample与groupby的区别:resample:在给定的时间单位内重取样groupby:对给定的数据条目进行统计 函数原型:DataFrame.resample(rule, how=None ...
- Pandas 基础(14) - DatetimeIndex and Resample
这一小节要介绍两个内容, 一个是 DatetimeIndex 日期索引, 另一个是 Resample, 这是一个函数, 可以通过参数的设置, 来调整数据的查询条件, 从而得到不同的结果. 首先看下关于 ...
- pandas的resample重采样
Pandas中的resample,重新采样,是对原样本重新处理的一个方法,是一个对常规时间序列数据重新采样和频率转换的便捷的方法. 降采样:高频数据到低频数据 升采样:低频数据到高频数据 主要函数:r ...
- pandas之时间序列(data_range)、重采样(resample)、重组时间序列(PeriodIndex)
1.data_range生成时间范围 a) pd.date_range(start=None, end=None, periods=None, freq='D') start和end以及freq配合能 ...
- 10 Minutes to pandas
摘要 一.创建对象 二.查看数据 三.选择和设置 四.缺失值处理 五.相关操作 六.聚合 七.重排(Reshaping) 八.时间序列 九.Categorical类型 十.画图 十一 ...
- 【转载】使用Pandas进行数据提取
使用Pandas进行数据提取 本文转载自:蓝鲸的网站分析笔记 原文链接:使用python进行数据提取 目录 set_index() ix 按行提取信息 按列提取信息 按行与列提取信息 提取特定日期的信 ...
- 10分钟学习pandas
10 Minutes to pandas This is a short introduction to pandas, geared mainly for new users. You can se ...
- pandas 透视表 pivot_table
The function pandas.pivot_table can be used to create spreadsheet-style pivot tables. It takes a num ...
随机推荐
- 51单片机 | A/D转换器实现数字电压表实例
———————————————————————————————————————————— ADC0809 - - - - - - - - - - - - - - - - - - - - - - - - ...
- httpModules 与 httpHandlers
ASP.NET对请求处理的过程:当请求一个*.aspx文件的时候,这个请求会被inetinfo.exe进程截获,它判断文件的后缀(aspx)之后,将这个请求转交给ASPNET_ISAPI.dll,AS ...
- DICOM医学图像处理:WEB PACS初谈二,图像的传输
背景: 如前一篇专栏博文所述,借助于CGI或FastCGI技术转发浏览器发送过来的用户请求,启动本地的DCMTK和CxImage库响应.然后将处理结果转换成常规图像返回到浏览器来实现Web PACS. ...
- windows 下编译64位ffmpeg
window下如何编译ffmpeg 前文已有介绍,前面介绍的都是如何编译32位的库,本文主要介绍window 下如何编译64位ffmpeg库. 一.搭建编译环境 1.下载 windows下编译64位F ...
- 解决:cant't run '/etc/init.d/rcS':No such file or directory
Linux内核启动时提示这种错误:cant't run '/etc/init.d/rcS':No such file or directory 请用vim打开文件:/etc/init.d/rcS 观察 ...
- lvs+keepalived+bind实现负载均衡高可用智能dns
整体架构: 1.IP地址规划: Dns1:172.28.0.54 Dns2:172.28.0.55 Dr服务器主:172.28.0.57 Dr服务器从:172.28.0.67 Vip:172.28.0 ...
- xgboost 特征选择,筛选特征的正要性
import pandas as pd import xgboost as xgb import operator from matplotlib import pylab as plt def ce ...
- SQL 根据表获取字段字符串
SQLSERVER查询单个数据表所有字段名组合成的字符串脚本 --SQLSERVER查询单个数据表所有字段名组合成的字符串脚本 --应用场合: 用于生成SQL查询字符串中select 字段名列表1 f ...
- docker 查看容器挂载的目录
$ docker inspect container_name | grep Mounts -A 20
- Ubuntu14下Hadoop开发<1> 基础环境安装
准备了一台淘汰的笔记本.单核CPU.3G内存.160G硬盘:准备一个2G的U盘 在官网下载了64位的14.04版本号(麒麟)的ISO.下载UNetbootin(Ubuntu专用U盘安装工具) 使用UN ...