用法:
Index.set_names(names, level=None, inplace=False)
設置索引或多索引名稱。能夠部分和按級別設置新名稱。
- names:標簽或標簽列表
要設置的名稱。
- level:int,標簽或 int 或標簽列表,可選
如果索引是 MultiIndex,則要設置的級別(所有級別都沒有)。否則級別必須為無。
- inplace:布爾值,默認為 False
直接修改對象,而不是創建新的 Index 或 MultiIndex。
- index
與調用者相同的類型,如果 inplace 為 True,則為 None。
參數:
返回:
例子:
>>> import cudf >>> idx = cudf.Index([1, 2, 3, 4]) >>> idx Int64Index([1, 2, 3, 4], dtype='int64') >>> idx.set_names('quarter') Int64Index([1, 2, 3, 4], dtype='int64', name='quarter') >>> idx = cudf.MultiIndex.from_product([['python', 'cobra'], ... [2018, 2019]]) >>> idx MultiIndex([('python', 2018), ('python', 2019), ( 'cobra', 2018), ( 'cobra', 2019)], ) >>> idx.names FrozenList([None, None]) >>> idx.set_names(['kind', 'year'], inplace=True) >>> idx.names FrozenList(['kind', 'year']) >>> idx.set_names('species', level=0, inplace=True) >>> idx.names FrozenList(['species', 'year'])
相關用法
- Python cudf.Index.sort_values用法及代碼示例
- Python cudf.Index.is_boolean用法及代碼示例
- Python cudf.Index.astype用法及代碼示例
- Python cudf.Index.is_numeric用法及代碼示例
- Python cudf.Index.union用法及代碼示例
- 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.set_names。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。