博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
pandas groupby
阅读量:6568 次
发布时间:2019-06-24

本文共 1625 字,大约阅读时间需要 5 分钟。

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()

 

本文转自罗兵博客园博客,原文链接:http://www.cnblogs.com/hhh5460/p/5596374.html,如需转载请自行联系原作者
你可能感兴趣的文章
ThreadLocal
查看>>
第一次作业-准备篇
查看>>
cnzz统计代码引起的Bad Request - Request Too Long
查看>>
MinGW安装与使用简介
查看>>
Sublime Text 3 遇到的一些小坑的解决方法
查看>>
JSP之9大对象
查看>>
sql 递归查询
查看>>
KMP C++
查看>>
HDU1506 Largest Rectangle in a Histogram(算竞进阶习题)
查看>>
HTTP响应状态码
查看>>
crushmap磁盘智能分组
查看>>
《算法导论》读书笔记--第三章 函数的增长
查看>>
《利用python进行数据分析》读书笔记--第八章 绘图和可视化
查看>>
栈的操作
查看>>
Flask 备注一(单元测试,Debugger, Logger)
查看>>
ElasticSearch(八):springboot集成ElasticSearch集群并使用
查看>>
Java基础学习_01 概述及环境配置
查看>>
20165239其米仁增3
查看>>
[Usaco2005 Open]Disease Manangement 疾病管理 BZOJ1688
查看>>
P2657 [SCOI2009]windy数 数位dp入门
查看>>