Extract all numbers from a given array using NumPy

In this python numpy program, we will extract all numbers from a given array using NumPy

Steps to solve the program
  1. Import the numpy library as np.
  2. Create an array using np.array().
  3. Extract all numbers from a given array that are greater than a specified number using Indexing and logic.
  4. Print the output.
				
					import numpy as np
x = np.array([[6, 5],
              [10, 9],
              [8, 7]])
print("Array: ",x)
print("Values bigger than 7 =", x[x>7])
				
			

Output :

				
					Array:  [[ 6  5]
 [10  9]
 [ 8  7]]
Values bigger than 7 = [10  9  8]
				
			

sort a given array by column in ascending order.

replace all numbers in a given array that is equal or greater than a given number.

Leave a Comment