将列表转换为数组时,最好使用np.array()或np.asarray()

时间:2018-07-30 18:18:11

标签: python numpy

假设我已经有一个创建并分配给变量的列表。

example = [1, 2, 3, 4]

然后稍后在我的代码中,我要将其转换为数组。哪个是更好的做法?

example = np.array(example)
#or
example = np.asarray(example)

还是还有另一种更好的方法?

0 个答案:

没有答案