在 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
在 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刪除。