Explain the NumPy Array Shape
Ask by ICSM Computer
Updated 10 Nov 2025
Syntax
Example 1: 1D Array
Output:
This means the array has 4 elements in 1 dimension.
Example 2: 2D Array
Output:
This means there are 2 rows and 3 columns.
Example 3: 3D Array
Output:
This means there are 2 blocks, each containing a 2×2 matrix.
Example 4: Using
.reshape()to change shapeOutput:
Example 5: Get number of dimensions
Output:
Returns the number of dimensions.
Summary
arr.shape(3, 4)arr.ndim2arr.size12