Program to interchange the rows of a matrix using NumPy.

In this python numpy program, we will interchange the rows of a matrix using NumPy.

Steps to solve the program
  1. Import the numpy library as np.
  2. Create a matrix using np.array().
  3. Interchange the rows of a matrix using transpose().
  4. Print the output.
				
					import numpy as np
x = np.array([[5, 6],
              [7, 8],
              [9, 10]])
print(x.transpose())
				
			

Output :

				
					[[ 5  7  9]
 [ 6  8 10]]
				
			

create a one-dimensional array.

sort an array by row in ascending order.

Leave a Comment