pandas.DataFrame.groupby

DataFrame.groupby(by=None, axis=0, level=None, as_index=True, sort=True, group_keys=True, squeeze=False, **kwargs)

Group series using mapper (dict or key function, apply given function to group, return result as series) or by a series of columns.
    Parameters:

by : mapping function / list of functions, dict, Series, or tuple /

list of column names. Called on each element of the object index to determine the groups. If a dict or Series is passed, the Series or dict VALUES will be used to determine the groups

axis : int, default 0

level : int, level name, or sequence of such, default None

If the axis is a MultiIndex (hierarchical), group by a particular level or levels

as_index : boolean, default True

For aggregated output, return object with group labels as the index. Only relevant for DataFrame input. as_index=False is effectively “SQL-style” grouped output

sort : boolean, default True

Sort group keys. Get better performance by turning this off. Note this does not influence the order of observations within each group. groupby preserves the order of rows within each group.

group_keys : boolean, default True

When calling apply, add group keys to index to identify pieces

squeeze : boolean, default False

reduce the dimensionality of the return type if possible, otherwise return a consistent type

Returns:

GroupBy object

Examples

DataFrame results

>>> data.groupby(func, axis=0).mean()
>>> data.groupby(['col1', 'col2'])['col3'].mean()

DataFrame with hierarchical index

>>> data.groupby(['col1', 'col2']).mean()

pandas groupby的更多相关文章

  1. python pandas groupby

    转自 : https://blog.csdn.net/Leonis_v/article/details/51832916 pandas提供了一个灵活高效的groupby功能,它使你能以一种自然的方式对 ...

  2. pandas - groupby 深入及数据清洗案例

    import pandas as pd import numpy as np 分割-apply-聚合 大数据的MapReduce The most general-purpose GroupBy me ...

  3. Pandas | GroupBy 分组

    任何分组(groupby)操作都涉及原始对象的以下操作之一: 分割对象 应用一个函数 结合的结果 在许多情况下,我们将数据分成多个集合,并在每个子集上应用一些函数.在应用函数中,可以执行以下操作: 聚 ...

  4. [Python Cookbook] Pandas Groupby

    Groupby Count # Party’s Frequency of donations nyc.groupby(’Party’)[’contb receipt amt’].count() The ...

  5. pandas groupby 分组操作

    最一般化的groupby 方法是apply. tips=pd.read_csv('tips.csv') tips[:5] 新生成一列 tips['tip_pct']=tips['tip']/tips[ ...

  6. pandas groupby生成新的dataframe

    mark地址:https://blog.csdn.net/weixin_41784098/article/details/79486259

  7. pandas groupby 使用

    so useful~ refer to: http://kekefund.com/2016/06/17/pandas-groupby/

  8. 数据分析处理库Pandas——groupby

    DataFrame结构 指定列中相同元素求和 备注:指定列"key"中相同元素的"data"值求和. 备注:指定列"A"和"B&q ...

  9. Python人工智能学习笔记

    Python教程 Python 教程 Python 简介 Python 环境搭建 Python 中文编码 Python 基础语法 Python 变量类型 Python 运算符 Python 条件语句 ...

随机推荐

  1. iOS 准确计算某个时间点距现在的时间差的代码 如"几分钟,几小时,几秒之前" ,

    利用时间戳来进行计算  ,需要给它一个时间: NSString *countTime = [self intervalSinceNow:@"2015-10-29 17:00:00" ...

  2. Reverse反转算法+斐波那契数列递归+Reverse反转单链表算法--C++实现

    Reverse反转算法 #include <iostream> using namespace std; //交换的函数 void replaced(int &a,int & ...

  3. android intent 5.1

    1.intent 6 items action, data(uri &type),Component name,Extras,flags 2.data---uri & type 不管使 ...

  4. maven问题-"resolution will not be reattempted until the update interval of MyRepo has elapsed"

    最近在家里写maven程序的时候老是出现问题,有些问题到了公司就突然消失了. 在修改pom文件后保存的反应还是比较明显的,家里的网遇到有些依赖根本下载不了..墙. 但是到了公司,不但速度快,几乎啥都能 ...

  5. linux crontab & 每隔10秒执行一次

    linux下定时执行任务的方法  在LINUX中你应该先输入crontab -e,然后就会有个vi编辑界面,再输入0 3 * * 1 /clearigame2内容到里面 :wq 保存退出. 在LINU ...

  6. C# Process运行cmd命令的异步回显

    以下的代码为new Process() 调用cmd命令,并将结果异步回显到Form的例子: 以下的代码为new Process() 调用cmd命令,并将结果异步回显到Form的例子: [csharp] ...

  7. ERP产品价格成本计算的几个方法(转)

          一般财务计算产品价格又很多方法,我这里做了几个供参考,实体属性主要是编号.数量.价格等,这里就不列出了. /// <summary> /// 先进先出算法 /// </s ...

  8. linux常用查看日志命令

    转自:http://yinfeifei.iteye.com/blog/779217 1.cat命令: 功能:1)显示整个文件. 示例: $ cat fileName 2)把文件串连接后传到基本输出,如 ...

  9. SQL将用户表中已存在的数据所有姓名(汉字)转换为拼音首字母

    实现方法: --函数 Create function [dbo].[fn_GetPy](@str nvarchar(4000)) returns nvarchar(4000) --用于加密 --WIT ...

  10. 烂泥:centos6.4服务器添加新硬盘

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 公司FTP服务器的空间又不够了,唉,没有办法只能新加硬盘了.因为以前没有给Linux服务器添加过硬盘,所以只能先在虚拟机中进行模拟. 新加硬盘的操作步骤 ...