当前位置:   article > 正文

python中astype用法_python里的astype是什么意思?

astype

展开全部

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 数组元素的类型

resize,m_lfit,w_600,h_800,limit_1

3,astype 修改数据类型

resize,m_lfit,w_600,h_800,limit_1

扩展资料

python里的astype的运用代码:

#astype的应用

e=np.linspace(1,5,20)

print(e)

#>>>

[1. 1.21052632 1.42105263 1.63157895 1.84210526 2.05263158

2.26315789 2.47368421 2.68421053 2.89473684 3.10526316 3.31578947

3.52631579 3.73684211 3.94736842 4.15789474 4.36842105 4.57894737

4.78947368 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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/730267
推荐阅读
相关标签
  

闽ICP备14008679号