Perform the following operations to Manipulating the Dimensions and the Shape of Arrays(Flips the order of the Axes) array2d = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]). Data science using Python in Anaconda - Jupyter

 Question

1. Permute the dimensions of an array

2. Flip array in the left/right direction

3. Flip array in the up/down direction

4. Rotate an array by 90 degrees in the plane specified by axes



Program: -

import numpy as np
array2d = np.array([[123], [456], [789]])
print("Orignal Array:- \n",array2d,"\n")
print("Permute the dimensions of an array :-",np.transpose(array2d)) #Unable to find
print("Flip array in the left/right direction :- \n",np.fliplr(array2d))
print("Flip array in the up/down direction :- \n",np.flipud(array2d))
print("Rotate an array by 90 degrees in the plane specified by axes :- \n",np.rot90(array2d))


Output: -
Orignal Array:- [[1 2 3] [4 5 6] [7 8 9]] Permute the dimensions of an array :- [[1 4 7] [2 5 8] [3 6 9]] Flip array in the left/right direction :- [[3 2 1] [6 5 4] [9 8 7]] Flip array in the up/down direction :- [[7 8 9] [4 5 6] [1 2 3]] Rotate an array by 90 degrees in the plane specified by axes :- [[3 6 9] [2 5 8] [1 4 7]]