ndarray对象(即 NumPy数组)中的元素类型可以一致,也可以不一致。
但是如果我们在创建 ndarray对象时使用了 dtype 参数,则数组对象元素类型必须一致,否则报错
ndarray的数据类型

f=np.array(range(5),dtype=np.int64)
print(f)
print(f.dtype)
f_float=f.astype(np.float64)
print(f_float)
print(f_float.dtype)

相关文章:

  • 2022-01-19
  • 2021-09-27
  • 2021-07-06
  • 2022-12-23
  • 2021-09-10
  • 2022-12-23
  • 2021-12-05
  • 2021-12-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2022-12-23
  • 2021-09-06
  • 2022-12-23
相关资源
相似解决方案