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 条件语句 ...
随机推荐
- C语言的判断语句
// // main.c // homeWork1222 //// #include <stdio.h> int main(int argc, const char * argv[]) { ...
- iOS 正则表达式判断邮箱、身份证..是否正确
//邮箱 + (BOOL) validateEmail:(NSString *)email { NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Z ...
- IOS开发中返回值为null时的处理
在IOS开发中,如果得到了null返回值很容易造成程序崩溃,null和nil的判断方法不同. nil的判断方法: if(data==nil) { NSLog(@"data is n ...
- PHP读写XML文件的四种方法
PHP对XML文件进行读写操作的方法一共有四种,分别是:字符串方式直接读写.DOMDocument读写. XMLWrite写和XMLReader读.SimpleXML读写,本文将依次对这四种方法进行介 ...
- Java并发大师Brain Goetz和Doug Lea 的中英文博客文章地址
Java并发大师Brain Goetz和Doug Lea是Java并发方面最权威的人物,他的文章绝对是最具有参考价值的,值得仔仔细细的推敲和研究. Brain Goetz 中文地址:http://ww ...
- SQL中获取最近的N个半年度
直接上代码: --获取往前推的N个半年度 CREATE FUNCTION F3_GetRecentNHalfYear ( @N INT ) RETURNS @Result TABLE ( Year S ...
- jacob 实现Office Word文件格式转换
关于jacob用法,百度一下就会发现几乎都是复制2004年一个代码,那段代码实现的是从一个目录读取所有doc文件,然后把它转html格式. 为了便习学习和使用,我把代码看懂后精简了一下,得出不少新结论 ...
- D_S 顺序栈的基本操作
// main.cpp #include <iostream> using namespace std; #include "Status.h" typedef in ...
- GitHub中wiki的Markdown编辑方法!!
Hello MarkDown!正常的文本 一级大标题用一个#号 一级中等标题用两个#号 一级小标题用三个#号(一次类推,一共有6级标题) 下面是无序列表 无序标题1-只需要在标题前面加上*号就可以了或 ...
- Hadoop Yarn core concepts
The fundamental idea of YARN is to split the two major responsibilities of the JobTracker—that is, r ...