用法:
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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。