用法:
Index.astype(dtype, copy=False)
創建一個將值轉換為 dtypes 的索引。新索引的類別由 dtype 確定。當無法進行轉換時,會引發 ValueError 異常。
- dtype:numpy 數據類型
使用 numpy.dtype 將整個 Index 對象轉換為。
- copy:布爾值,默認為 False
默認情況下, astype 總是返回一個新分配的對象。如果 copy 設置為 False 並且滿足 dtype 的內部要求,則使用原始數據創建新索引或返回原始索引。
- index
將值轉換為指定 dtype 的索引。
參數:
返回:
例子:
>>> import cudf >>> index = cudf.Index([1, 2, 3]) >>> index Int64Index([1, 2, 3], dtype='int64') >>> index.astype('float64') Float64Index([1.0, 2.0, 3.0], dtype='float64')
相關用法
- Python cudf.Index.append用法及代碼示例
- Python cudf.Index.is_boolean用法及代碼示例
- Python cudf.Index.set_names用法及代碼示例
- Python cudf.Index.is_numeric用法及代碼示例
- Python cudf.Index.sort_values用法及代碼示例
- 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.is_interval用法及代碼示例
- Python cudf.Index.intersection用法及代碼示例
- Python cudf.Index.is_floating用法及代碼示例
- Python cudf.Index.fillna用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.Index.astype。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。