ndarray - Methods and Data Type

Premium

Once you have created an array, you can check its various attributes using the inbuilt functions. Some of these are described below:

ndarray.ndim

Returns the number of array dimensions.

1>>> a
2array([[ 1.,  2.,  3.],
3       [ 4.,  5.,  6.]])
4>>> a.ndim
52
6>>> x = np.array([1, 2, 3])
7>>> x.ndim
81
9

Unlock Premium Content

Upgrade your account to access the full article, downloads, and exercises.

You'll get access to:

  • Access complete tutorials and examples
  • Download source code and resources
  • Follow along with practical exercises
  • Get in-depth explanations