databricks.koalas.Index.astype

Index.astype(dtype)

Cast a Koalas object to a specified dtype dtype.

Parameters
dtypedata type

Use a numpy.dtype or Python type to cast entire pandas object to the same type.

Returns
castedsame type as caller

See also

to_datetime

Convert argument to datetime.

Examples

>>> ser = ks.Series([1, 2], dtype='int32')
>>> ser
0    1
1    2
Name: 0, dtype: int32
>>> ser.astype('int64')
0    1
1    2
Name: 0, dtype: int64
>>> ser.rename("a").to_frame().set_index("a").index.astype('int64')
Int64Index([1, 2], dtype='int64', name='a')