pandas groupby

简介: pandas.DataFrame.groupbyDataFrame.groupby(by=None, axis=0, level=None, as_index=True, sort=True, group_keys=True, squeeze=False, **kwargs)Group series...

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

 



目录
相关文章
|
JavaScript 前端开发
input 输入 限制 大全
input 输入 限制 大全
495 0
|
算法 数据挖掘
【数据挖掘】岭回归Ridge讲解及实战应用(超详细 附源码)
【数据挖掘】岭回归Ridge讲解及实战应用(超详细 附源码)
643 0
|
人工智能 算法 数据挖掘
技术沙龙直播|3D-Speaker多模态说话人开源详解
技术沙龙直播|3D-Speaker多模态说话人开源详解
|
敏捷开发 安全 测试技术
敏捷项目管理的原则、好处、工具、提示以及何时进行转换
敏捷项目管理的原则、好处、工具、提示以及何时进行转换
|
人工智能 安全 算法
智能时代的桥梁:人工智能技术在现代交通系统中的应用
本文将探讨人工智能(AI)技术在现代交通系统中的创新性应用。通过分析AI如何优化交通流量、提高安全性和增强用户体验,我们将揭示这一技术如何成为连接智能城市与高效出行的关键纽带。文章还将讨论AI技术面临的挑战及其对未来交通发展的潜力。
|
存储 C语言 Perl
西门子S7-1200的变量如何使用?什么是局部变量和全局变量?临时变量和静态变量有什么区别?
今天给大家讲一下什么是局部变量、全局变量、临时变量、静态变量,这些变量都有什么区别,以及在西门子S7-1200中这些变量如何来使用。
西门子S7-1200的变量如何使用?什么是局部变量和全局变量?临时变量和静态变量有什么区别?
IP地址分类
IP地址分类相关内容
669 1
|
自然语言处理 算法 视频直播
如何 get 一个终身免费续期的定制数字人?
活动有效期到什么时间? 限时福利活动有效期为 2023 年 11 月 30 日 24 点前请在规定期内完成数字人定制任务提交操作。
321 2
|
存储 SQL 数据库
AnalyticDB(ADB)+LLM:构建AIGC时代下企业专属Chatbot
本文讲述如何基于向量数据库+LLM(大语言模型),打造更智能的企业专属Chatbot。
AnalyticDB(ADB)+LLM:构建AIGC时代下企业专属Chatbot
|
Dart 前端开发 JavaScript
程序员喜欢一句话代码的浪漫
作为一名合格的程序员,不会通过代码来制造浪漫,有点说不过去。每一年在逢年过节的时候,程序员都会通过自己的专业特长来制造专属浪漫,比如用代码实现一个心形的图案、用代码实现嫦娥奔月、用代码实现输出“土味情话”等等,这都是非常浪漫的瞬间。
529 0
程序员喜欢一句话代码的浪漫