numpy.ma.ndim#

ma.ndim(obj)[原始碼]#

傳回陣列的維度數量。

參數:
aarray_like

輸入陣列。如果它還不是 ndarray,則會嘗試轉換。

傳回:
number_of_dimensionsint

a 中的維度數量。純量是零維的。

參見

ndarray.ndim

等效方法

shape

陣列的維度

ndarray.shape

陣列的維度

範例

>>> import numpy as np
>>> np.ndim([[1,2,3],[4,5,6]])
2
>>> np.ndim(np.array([[1,2,3],[4,5,6]]))
2
>>> np.ndim(1)
0