[ Web Proxy ]
URL:
Viewing: https://numpy.org/doc/stable/reference/generated/../generated/numpy.ndim.html [Back]  [Original]

numpy.ndim — NumPy v2.5 Manual
Back to top
Search the docs ...:

numpy.ndim#

numpy.ndim(a)[source]#

Return the number of dimensions of an array.

Parameters:
aarray_like

Input array. If it is not already an ndarray, a conversion is attempted.

Returns:
number_of_dimensionsint

The number of dimensions in a. Scalars are zero-dimensional.

See also

ndarray.ndim

equivalent method

shape

dimensions of array

ndarray.shape

dimensions of array

Examples

Try it in your browser!
>>> 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

Web Proxy Viewer  |  New URL  |  Original Page