为什么在这个numpy数组中ndim = 2?

时间:2017-01-05 05:49:13

标签: python numpy

>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

1 个答案:

答案 0 :(得分:1)

ndimlen(a.shape)

相同

在您的情况下,您有2个尺寸,第一个尺寸为3,第二个尺寸为5