当前位置:   article > 正文

numpy数组的astype()函数_numpy astype

numpy astype

https://numpy.org/doc/stable/reference/generated/numpy.ndarray.astype.html#numpy.ndarray.astype

ndarray.astype(dtype, order=‘K’, casting=‘unsafe’, subok=True, copy=True) 返回一个数组的拷贝,转换成指定的类型。

示例:

import numpy as np

x = np.array([100, 20, 254])
print('x = ', x)

y = x.astype("float32")
print('y = ', y)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

输出:
在这里插入图片描述

声明:本文内容由网友自发贡献,转载请注明出处:【wpsshop】
推荐阅读
相关标签
  

闽ICP备14008679号