4. Dimensions in Array#
import numpy as np
4.1. One dimensional Array#
np.array([1,2,3,4])
array([1, 2, 3, 4])
Represented in single axis
4.2. Two Dimensional Array#
np.array([[1,2],[3,4]])
array([[1, 2],
[3, 4]])
np.array([[1,2,3,4]])
array([[1, 2, 3, 4]])
Represented in rows and columns as matrix
means 2 axis are required
Representation
0 1
0 [1,2]
1 [3.4]
Axis becomes 0,1 and 0,1
at (0,0) 1 is present
at (0,1) 2 is present
at (1,0) 3 is present
at (1,1) 4 is present
4.3. Checking dimension of array#
ndim attribute is used
a=np.array([1,2,3,4])
a.ndim
1
b=np.array([[1,2,3,4]])
b.ndim
2