Movatterモバイル変換


[0]ホーム

URL:


Skip to main content
Ctrl+K

pandas.Index.astype#

Index.astype(dtype,copy=True)[source]#

Create an Index with values cast to dtypes.

The class of a new Index is determined by dtype. When conversion isimpossible, a TypeError exception is raised.

Parameters:
dtypenumpy dtype or pandas type

Note that any signed integerdtype is treated as'int64',and any unsigned integerdtype is treated as'uint64',regardless of the size.

copybool, default True

By default, astype always returns a newly allocated object.If copy is set to False and internal requirements on dtype aresatisfied, the original data is used to create a new Indexor the original Index is returned.

Returns:
Index

Index with values cast to specified dtype.

Examples

>>>idx=pd.Index([1,2,3])>>>idxIndex([1, 2, 3], dtype='int64')>>>idx.astype('float')Index([1.0, 2.0, 3.0], dtype='float64')

[8]ページ先頭

©2009-2025 Movatter.jp