用法:
Series.groupby(by=None, axis=0, level=None, as_index=True, sort=False, group_keys=True, squeeze=False, observed=False, dropna=True)
使用映射器或按一系列列对系列进行分组。
groupby 操作涉及拆分对象、应用函数和组合结果的某种组合。这可用于对大量数据进行分组并在这些组上进行计算操作。
- by:映射、函数、标签或标签列表
用于确定 groupby 的组。如果 by 是一个函数,它会在对象索引的每个值上调用。如果传递了 dict 或 Series,则 Series 或 dict VALUES 将用于确定组(Series 的值首先对齐;参见 .align() 方法)。如果传递了一个cupy数组,则使用这些值as-is确定组。一个标签或标签列表可以通过 self 中的列传递给 group。请注意,元组被解释为(单个)键。
- level:int,级别名称或此类的序列,默认无
如果轴是 MultiIndex(分层),则按特定级别或多个级别分组。
- as_index:布尔值,默认为真
对于聚合输出,返回以组标签为索引的对象。仅与 DataFrame 输入相关。 as_index=False 实际上是 “SQL-style” 分组输出。
- sort:布尔值,默认为 False
按组键对结果进行排序。与 Pandas 不同,cudf 默认为
False
以获得更好的性能。请注意,这不会影响每组内的观察顺序。 Groupby 保留每个组内的行顺序。
- 系列分组
返回包含有关组的信息的 groupby 对象。
参数:
返回:
例子:
>>> ser = cudf.Series([390., 350., 30., 20.], ... index=['Falcon', 'Falcon', 'Parrot', 'Parrot'], ... name="Max Speed") >>> ser Falcon 390.0 Falcon 350.0 Parrot 30.0 Parrot 20.0 Name: Max Speed, dtype: float64 >>> ser.groupby(level=0).mean() Falcon 370.0 Parrot 25.0 Name: Max Speed, dtype: float64 >>> ser.groupby(ser > 100).mean() Max Speed False 25.0 True 370.0 Name: Max Speed, dtype: float64
相关用法
- Python cudf.Series.gt用法及代码示例
- Python cudf.Series.ge用法及代码示例
- Python cudf.Series.ceil用法及代码示例
- Python cudf.Series.update用法及代码示例
- Python cudf.Series.max用法及代码示例
- Python cudf.Series.head用法及代码示例
- Python cudf.Series.reindex用法及代码示例
- Python cudf.Series.interleave_columns用法及代码示例
- Python cudf.Series.min用法及代码示例
- Python cudf.Series.nlargest用法及代码示例
- Python cudf.Series.to_frame用法及代码示例
- Python cudf.Series.mask用法及代码示例
- Python cudf.Series.notnull用法及代码示例
- Python cudf.Series.isnull用法及代码示例
- Python cudf.Series.rmod用法及代码示例
- Python cudf.Series.map用法及代码示例
- Python cudf.Series.nsmallest用法及代码示例
- Python cudf.Series.data用法及代码示例
- Python cudf.Series.lt用法及代码示例
- Python cudf.Series.product用法及代码示例
注:本文由纯净天空筛选整理自rapids.ai大神的英文原创作品 cudf.Series.groupby。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。