numpy.ndim(a)
Return the number of dimensions of an array.
Parameters:aarray_likeInput array. If it is not already an ndarray, a conversion is attempted.
Returns:number_of_dimensionsintThe number of dimensions in a. Scalars are zero-dimensional.
Examples
>>> importnumpyasnp>>> np.ndim([[1,2,3],[4,5,6]])2>>> np.ndim(np.array([[1,2,3],[4,5,6]]))2>>> np.ndim(1)0