Python 为什么在这个numpy数组中ndim=2?
Python 为什么在这个numpy数组中ndim=2?,python,numpy,Python,Numpy,ndim与len(a.shape) 在本例中,您有两个尺寸,第一个尺寸为3,第二个尺寸为5 >import numpy as np >a = np.arange(15).reshape(3, 5) ([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14]]) > a.shape (3, 5) > a.ndim 2 /// how to calculate it for any
ndim
与len(a.shape)
在本例中,您有两个尺寸,第一个尺寸为3,第二个尺寸为5
>import numpy as np
>a = np.arange(15).reshape(3, 5)
([[ 0, 1, 2, 3, 4],
[ 5, 6, 7, 8, 9],
[10, 11, 12, 13, 14]])
> a.shape
(3, 5)
> a.ndim
2 /// how to calculate it for any narray