python中astype用法_python里的astype是什么意思?(Python.org)
展開全部
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.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
總結
以上是生活随笔為你收集整理的python中astype用法_python里的astype是什么意思?(Python.org)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Javascript 获取字符串字节数的
- 下一篇: 联合索引(多列索引)[通俗易懂]