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()的更多相关文章

  1. Python数据分析(三)pandas resample 重采样

    下方是pandas中resample方法的定义,帮助文档http://pandas.pydata.org/pandas-docs/stable/timeseries.html#resampling中有 ...

  2. pandas 时间序列resample

    resample与groupby的区别:resample:在给定的时间单位内重取样groupby:对给定的数据条目进行统计 函数原型:DataFrame.resample(rule, how=None ...

  3. Pandas 基础(14) - DatetimeIndex and Resample

    这一小节要介绍两个内容, 一个是 DatetimeIndex 日期索引, 另一个是 Resample, 这是一个函数, 可以通过参数的设置, 来调整数据的查询条件, 从而得到不同的结果. 首先看下关于 ...

  4. pandas的resample重采样

    Pandas中的resample,重新采样,是对原样本重新处理的一个方法,是一个对常规时间序列数据重新采样和频率转换的便捷的方法. 降采样:高频数据到低频数据 升采样:低频数据到高频数据 主要函数:r ...

  5. pandas之时间序列(data_range)、重采样(resample)、重组时间序列(PeriodIndex)

    1.data_range生成时间范围 a) pd.date_range(start=None, end=None, periods=None, freq='D') start和end以及freq配合能 ...

  6. 10 Minutes to pandas

    摘要   一.创建对象 二.查看数据 三.选择和设置 四.缺失值处理 五.相关操作 六.聚合 七.重排(Reshaping) 八.时间序列 九.Categorical类型   十.画图      十一 ...

  7. 【转载】使用Pandas进行数据提取

    使用Pandas进行数据提取 本文转载自:蓝鲸的网站分析笔记 原文链接:使用python进行数据提取 目录 set_index() ix 按行提取信息 按列提取信息 按行与列提取信息 提取特定日期的信 ...

  8. 10分钟学习pandas

    10 Minutes to pandas This is a short introduction to pandas, geared mainly for new users. You can se ...

  9. pandas 透视表 pivot_table

    The function pandas.pivot_table can be used to create spreadsheet-style pivot tables. It takes a num ...

随机推荐

  1. Linux常见服务器——DHCP服务器的搭建

    一.基础知识: 1.DHCP简介: DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)通常被应用在大型的局域网络环境中,主要作用是集中的管理.分配IP ...

  2. ListView滚动到底部判断

    参考:http://blog.csdn.net/jodan179/article/details/8017693 List13介绍的是ListView.OnScrollListener的 onScro ...

  3. YUV图像合成原理

    http://blog.csdn.net/zwz1984/article/details/50403150 http://zhongcong386.blog.163.com/blog/static/1 ...

  4. hbase和mapreduce开发 WordCount

    代码: /** * hello world by world 测试数据 * @author a * */ public class DefinedMapper extends Mapper<Lo ...

  5. MVC进阶学习--View和Controller之间的数据传递(一)

    1.使用ViewData ViewData 的是ControllerBase 的一个属性,是一个数据字典类型的,其实现代码如(这段代码来自asp.net MVC开源项目中源码)下: Code   1  ...

  6. centos6搭建docker镜像私服

    1.创建私服容器 docker run -d -e SETTINGS_FLAVOR=dev -e STORAGE_PATH=/tmp/registry -v /opt/data/registry:/t ...

  7. win10 下eclipse tomcat 热部署问题?

    前言: 问题的描述: 用的环境是maven,java,tomcat,win10 tomcat server配置如下 项目发布之后,修改jsp,报错,错误详情如下: 解决办法.勾选server opti ...

  8. 【Atheros】网卡驱动速率调整算法概述

    我做网卡驱动,最主要的内容就是设计和改进速率调整算法,随着802.11协议簇的新标准越来越多,速率越来越高,调制编码方式也越来越多,一般来说,速率越高越可能丢包,速率越低越稳定,这是整体状况,但不是必 ...

  9. WPF使用X:Static做多语言支持

    让程序支持多语言,一般把需要显示的字符串保存在一个资源类的static属性中. <!--[if !supportLists]--> <!--[endif]--> 微软的WPF程 ...

  10. String、StringBuilder、 StringBuffer 深入分析 源代码解析

    java学习有一段时间了.但学习的东西都是框架等东西,java基础知识有点遗忘.所以重温一下java基础知识.写写文章里面有错的希望大家指正共同进步~~ 一.String 大家常常会说使用" ...