用法:
cudf.pivot(data, index=None, columns=None, values=None)
返回由給定索引和列值組織的重構 DataFrame。
根據列值重塑數據(生成“pivot” 表)。使用指定
index
/columns
中的唯一值來形成結果 DataFrame 的軸。- index:列名,可選
用於構造結果索引的列。
- columns:列名,可選
Column 用於構造結果的列。
- values:列名或列名列表,可選
重新排列其值以產生結果的列。如果未指定,則使用 DataFrame 的所有剩餘列。
- DataFrame
參數:
返回:
例子:
>>> a = cudf.DataFrame() >>> a['a'] = [1, 1, 2, 2] >>> a['b'] = ['a', 'b', 'a', 'b'] >>> a['c'] = [1, 2, 3, 4] >>> a.pivot(index='a', columns='b') c b a b a 1 1 2 2 3 4
結果中缺少值的樞軸:
>>> a = cudf.DataFrame() >>> a['a'] = [1, 1, 2] >>> a['b'] = [1, 2, 3] >>> a['c'] = ['one', 'two', 'three'] >>> a.pivot(index='a', columns='b') c b 1 2 3 a 1 one two <NA> 2 <NA> <NA> three
相關用法
- Python cudf.core.column.string.StringMethods.is_vowel用法及代碼示例
- Python cudf.Series.ceil用法及代碼示例
- Python cudf.core.column.string.StringMethods.endswith用法及代碼示例
- Python cudf.Series.update用法及代碼示例
- Python cudf.DataFrame.mod用法及代碼示例
- Python cudf.DataFrame.isin用法及代碼示例
- Python cudf.core.column.string.StringMethods.title用法及代碼示例
- Python cudf.DataFrame.rmul用法及代碼示例
- Python cudf.Series.max用法及代碼示例
- Python cudf.DatetimeIndex.dayofweek用法及代碼示例
- Python cudf.DataFrame.apply用法及代碼示例
- Python cudf.core.column.string.StringMethods.contains用法及代碼示例
- Python cudf.core.column.string.StringMethods.rsplit用法及代碼示例
- Python cudf.DataFrame.exp用法及代碼示例
- Python cudf.Series.head用法及代碼示例
- Python cudf.DataFrame.drop用法及代碼示例
- Python cudf.core.column.string.StringMethods.zfill用法及代碼示例
- Python cudf.Series.reindex用法及代碼示例
- Python cudf.Series.interleave_columns用法及代碼示例
- Python cudf.core.series.DatetimeProperties.month用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.pivot。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。