在python中将np.ndarray转换为np.array [英] Convert np.ndarray to np.array in python
本文介绍了在python中将np.ndarray转换为np.array的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一些数据作为np.ndarray加载,需要将其转换为np.array.
I have some data loaded as a np.ndarray and need to convert it to a np.array.
是否有一种简便/快速的方法,而不必以其他方式重新加载数据?
Is there an easy/quick way of doing this without having to re-load the data in a different way?
我在教程中可以找到的所有信息似乎都涉及一种数组或另一种类型,而不是如何将数据从一种更改为另一种.
All the information I can find in tutorials seems to refer to one type of array or the other, but not how to change data from one to the other.
推荐答案
它们是相同的:numpy.array
是用于构造类型为numpy.ndarray
的对象的函数.
They are the same: numpy.array
is a function that constructs an object of type numpy.ndarray
.
>>> import numpy
>>> numpy.ndarray
<type 'numpy.ndarray'>
>>> numpy.array
<built-in function array>
>>> numpy.array([])
array([], dtype=float64)
>>> isinstance(numpy.array([]), numpy.ndarray)
True
这篇关于在python中将np.ndarray转换为np.array的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文