简体   繁体   English

Numpy 形状 function 用于一维数组

[英]Numpy shape function for single dimension array

I've started to learn NumPy, when I create an array and then invoke the.shape function, I understand how it works for most cases.我已经开始学习 NumPy,当我创建一个数组然后调用.shape function 时,我了解它在大多数情况下是如何工作的。 However, the result does not make sense to me for a single-dimensional array.但是,对于一维数组,结果对我来说没有意义。 Can someone please explain the outcome?有人可以解释一下结果吗?

array = np.array([4,5,6])
print(array.shape)

The outcome is (3,)结果是 (3,)

Output tulpe of ints in the "np.shape" function gives the lengths of the corresponding array dimension, and this tuple will be (n,m), in which n and m indicate row and columns, respectively. Output “np.shape”中的整数元组 function 给出了相应数组维度的长度,这个元组将是 (n,m),其中 n 和 m 分别表示行和列。 For a single dimension array, this Tuple will be just (n,), in which n indicates the number of array elements.对于一维数组,这个元组将只是 (n,),其中 n 表示数组元素的数量。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM