Articles → Numpy → Find The Minimum And Maximum Value In Numpy Arrays

Find The Minimum And Maximum Value In Numpy Arrays






Example


import numpy as np

# Create an array 
arr = np.random.randint(0,30,10)

print("Array:", arr)
print("Minimum value in array", arr.min())
print("Index of min value in array", arr.argmin())
print("Maximum value in array", arr.max())
print("Index of min value in array", arr.argmax())




  1. An array is created using randint function
  2. Find the minimum value in an array using min() function
  3. Find the index of minimum value in an array
  4. Find the maximum value in an array using max() function
  5. Find the index of maximum value in an array

Output


Picture showing the minimum and maximum value of the numpy array
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, March 27, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250