pandas groupby
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的更多相关文章
- python pandas groupby
转自 : https://blog.csdn.net/Leonis_v/article/details/51832916 pandas提供了一个灵活高效的groupby功能,它使你能以一种自然的方式对 ...
- pandas - groupby 深入及数据清洗案例
import pandas as pd import numpy as np 分割-apply-聚合 大数据的MapReduce The most general-purpose GroupBy me ...
- Pandas | GroupBy 分组
任何分组(groupby)操作都涉及原始对象的以下操作之一: 分割对象 应用一个函数 结合的结果 在许多情况下,我们将数据分成多个集合,并在每个子集上应用一些函数.在应用函数中,可以执行以下操作: 聚 ...
- [Python Cookbook] Pandas Groupby
Groupby Count # Party’s Frequency of donations nyc.groupby(’Party’)[’contb receipt amt’].count() The ...
- pandas groupby 分组操作
最一般化的groupby 方法是apply. tips=pd.read_csv('tips.csv') tips[:5] 新生成一列 tips['tip_pct']=tips['tip']/tips[ ...
- pandas groupby生成新的dataframe
mark地址:https://blog.csdn.net/weixin_41784098/article/details/79486259
- pandas groupby 使用
so useful~ refer to: http://kekefund.com/2016/06/17/pandas-groupby/
- 数据分析处理库Pandas——groupby
DataFrame结构 指定列中相同元素求和 备注:指定列"key"中相同元素的"data"值求和. 备注:指定列"A"和"B&q ...
- Python人工智能学习笔记
Python教程 Python 教程 Python 简介 Python 环境搭建 Python 中文编码 Python 基础语法 Python 变量类型 Python 运算符 Python 条件语句 ...
随机推荐
- iOS-协议与代理<转>
代理,又称委托代理(delegate),是iOS中常用的设计一种模式.顾名思义,它是把某个对象要做的事情委托给别的对象去做.那么别的对象就是这个对象的代理,代替它来打理要做的事.反映到程序中, 首先要 ...
- 为Xcode添加和备份快捷代码
有IOS开发经验的,相信你一定了解快捷代码的使用以及可以自定义代码,备份到XCode右下角,供下次使用. 那么,快捷代码备份到本地什么位置呢: 位置:~/Library/Developer/Xcode ...
- sublime text 3 如何安装 package control
sublime text3 是个很好的编辑工具,前端程序员觉得她很好,我是在一次视频中看到她能帮助自动完成很多快捷的操作. 为什么安装? 如果想要给sublime text 中安装别的插件(这里称呼为 ...
- jQuery学习笔记:整理一些常用的jQuery操作DOM事件
1.attr() .removeAttr() .attr() 方法可以传入一个名值对的参数,也可以传入一个包含2个以上名值对的对象参数,例如: .attr('src','images/a.jpg'); ...
- 如何修改opencms数据库配置
修改/webapps/opencms/WEB-INF/config/opencms.properties文件 什么情况下需要修改配置? 1. 使用过程中,修改数据库配置: 2. 太长时间没接触服务器, ...
- python启动服务器
3.* python -m http.server [port] & 2.* python -m SimpleHTTPServer [port] ...
- SQL2012数据库加密方法
1.非对称密钥来保护新的对称密钥 /*--测试环境 Microsoft SQL Server 2012 (SP1) - 11.0.3000.0 (X64) Oct 19 2012 13:38:57 C ...
- A Popup Progress Window
一个包含bar和取消而且不需要资源弹出窗口 1.构造函数 CProgressWnd(); CProgressWnd(CWnd* pParent, LPCTSTR strTitle, BOOL bSmo ...
- windows 搭建 solr 5.3.2
1. Tamcat 的安装,此不介绍 路径:F:\SolrTest\apache-tomcat-8.0.18 2. 解压 solr 5.3.2 路径:F:\Tool\solr-5.3.2 3. 复制s ...
- 第五篇 :微信公众平台开发实战Java版之如何获取公众号的access_token以及缓存access_token
一.access_token简介 为了使第三方开发者能够为用户提供更多更有价值的个性化服务,微信公众平台 开放了许多接口,包括自定义菜单接口.客服接口.获取用户信息接口.用户分组接口.群发接口等, 开 ...