用法:
Index.union(other, sort=None)
形成兩個索引對象的並集。
- other:索引或array-like
- sort:布爾或無,默認無
是否對結果索引進行排序。
- 無:對結果進行排序,除非當
self
和other
相等。self
或other
的長度為 0。
- False:不對結果進行排序。
- 無:對結果進行排序,除非當
- union: index
參數:
返回:
例子:
索引聯合 >>> 導入 cudf >>> 將 pandas 導入為 pd >>> idx1 = cudf.Index([1, 2, 3, 4]) >>> idx2 = cudf.Index([3, 4, 5 , 6]) >>> idx1.union(idx2) Int64Index([1, 2, 3, 4, 5, 6], dtype='int64')
多索引案例
>>> idx1 = cudf.MultiIndex.from_pandas( ... pd.MultiIndex.from_arrays( ... [[1, 1, 2, 2], ["Red", "Blue", "Red", "Blue"]] ... ) ... ) >>> idx1 MultiIndex([(1, 'Red'), (1, 'Blue'), (2, 'Red'), (2, 'Blue')], ) >>> idx2 = cudf.MultiIndex.from_pandas( ... pd.MultiIndex.from_arrays( ... [[3, 3, 2, 2], ["Red", "Green", "Red", "Green"]] ... ) ... ) >>> idx2 MultiIndex([(3, 'Red'), (3, 'Green'), (2, 'Red'), (2, 'Green')], ) >>> idx1.union(idx2) MultiIndex([(1, 'Blue'), (1, 'Red'), (2, 'Blue'), (2, 'Green'), (2, 'Red'), (3, 'Green'), (3, 'Red')], ) >>> idx1.union(idx2, sort=False) MultiIndex([(1, 'Red'), (1, 'Blue'), (2, 'Red'), (2, 'Blue'), (3, 'Red'), (3, 'Green'), (2, 'Green')], )
相關用法
- Python cudf.Index.is_boolean用法及代碼示例
- Python cudf.Index.astype用法及代碼示例
- Python cudf.Index.set_names用法及代碼示例
- Python cudf.Index.is_numeric用法及代碼示例
- Python cudf.Index.sort_values用法及代碼示例
- Python cudf.Index.is_integer用法及代碼示例
- Python cudf.Index.join用法及代碼示例
- Python cudf.Index.get_level_values用法及代碼示例
- Python cudf.Index.isin用法及代碼示例
- Python cudf.Index.rename用法及代碼示例
- Python cudf.Index.to_pandas用法及代碼示例
- Python cudf.Index.difference用法及代碼示例
- Python cudf.Index.is_object用法及代碼示例
- Python cudf.Index.from_pandas用法及代碼示例
- Python cudf.Index.is_categorical用法及代碼示例
- Python cudf.Index.append用法及代碼示例
- Python cudf.Index.is_interval用法及代碼示例
- Python cudf.Index.intersection用法及代碼示例
- Python cudf.Index.is_floating用法及代碼示例
- Python cudf.Index.fillna用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.Index.union。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。