type()、dtype()、astype() 用法


在 python 中,与数据类型相关函数及属性有三个:

名称 作用
type() 返回参数的数据类型
dtype() 返回数组中元素的数据类型
astype() 对数据类型进行转换

实例:

import numpy as np
a = np.arange(5)
type(a)
Out[4]: numpy.ndarray
a[0].dtype
Out[5]: dtype('int32')
a[0].astype(float)
Out[6]: 0.0


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM