用法:
DataFrame.pivot(index, columns, 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.DataFrame.pipe用法及代碼示例
- Python cudf.DataFrame.prod用法及代碼示例
- Python cudf.DataFrame.product用法及代碼示例
- Python cudf.DataFrame.pow用法及代碼示例
- Python cudf.DataFrame.mod用法及代碼示例
- Python cudf.DataFrame.isin用法及代碼示例
- Python cudf.DataFrame.rmul用法及代碼示例
- Python cudf.DataFrame.apply用法及代碼示例
- Python cudf.DataFrame.exp用法及代碼示例
- Python cudf.DataFrame.drop用法及代碼示例
- Python cudf.DataFrame.where用法及代碼示例
- Python cudf.DataFrame.median用法及代碼示例
- Python cudf.DataFrame.to_pandas用法及代碼示例
- Python cudf.DataFrame.take用法及代碼示例
- Python cudf.DataFrame.tail用法及代碼示例
- Python cudf.DataFrame.rfloordiv用法及代碼示例
- Python cudf.DataFrame.equals用法及代碼示例
- Python cudf.DataFrame.head用法及代碼示例
- Python cudf.DataFrame.count用法及代碼示例
- Python cudf.DataFrame.isna用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.DataFrame.pivot。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。