Table of Contents
Mastering Array Representation with NumPy in Python: A Complete Guide
Representation of Array Using numpy
array1d = np.array([1,2,3,4])
print("shape of array1d before reshaping: ", array1d.shape)
array1d = array1d.reshape(1,4)
print("shape of array1d after reshaping: ", array1d.shape)
#rank of matrix can be found using np.linalg.matrix_rank() function
print("array1d is a martrix of rank {}".format(np.linalg.matrix_rank(array1d)))
output:
shape of array1d before reshaping: (4,)
shape of array1d after reshaping: (1, 4)
array1d is a martrix of rank 1
-
The shape (4,) just represents that the array has 4 elements.
-
The shape (1, 4) represents that array has 4 elements with one row and four columns.
What Have You learned till now?
-
In this topic, you have read:
-
How to represent matrices using numpy?
-
How to perform dot product and element-wise product using numpy?
-
The concept of broadcasting and its implementation in Python.
-