大家好,欢迎来到IT知识分享网。
展开全部
astype是实现2113变量类型转换,例如
astype(type): returns a copy of the array converted to the specified type.a =
a.astype(‘Float64’)b = b.astype(‘Int32’)
Python中与数据5261类型4102相关函数及属性1653有如下三个:type/dtype/astype
type() 返回参数的数据类型
dtype 返回数组中元素的数据类型
astype() 对数据类型进行转换
python中type dtype astype 的用法
1,type 获取数据类型
2,dtype 数组元素的类型
3,astype 修改数据类型
扩展资料
python里的astype的运用代码:
#astype的应用
e=np.linspace(1,5,20)
print(e)
#>>>
[1. 1. 1. 1. 1. 2.0
2. 2. 2. 2. 3. 3.
3. 3. 3. 4. 4. 4.
4. 5. ]
”’
print(e.dtype)
#>>>float64
e=e.astype(int)
print(e)
#>>>[1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 5]
print(e.dtype)
#>>>int64
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/114665.html

