python中astype用法_python里的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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值