Advertisements
Advertisements
प्रश्न
What do you understand by rank of an ndarray?
लघु उत्तरीय
Advertisements
उत्तर
The rank of an ndarray means the number of dimensions (axes) present in the array. It tells us whether the array is one-dimensional, two-dimensional, three-dimensional, and so on.
- A 1-dimensional array has rank 1.
- A 2-dimensional array has rank 2.
- A 3-dimensional array has rank 3.
import numpy as np
a = np.array([[1, 2], [3, 4]])
print(a.ndim)
Output:
2
Therefore, the rank of the given ndarray is 2.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
