Title: Find The Maximum And Minimum
Slug: find_maximum_and_minimum
Summary: How to find the maximum, minimum, and average of the elements in an array.
Date: 2017-09-03 12:00
Category: Machine Learning
Tags: Vectors Matrices Arrays
Authors: Chris Albon
In [8]:
# Load library
import numpy as np
In [9]:
# Create matrix
matrix = np.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
In [10]:
# Return maximum element
np.max(matrix)
Out[10]:
In [11]:
# Return minimum element
np.min(matrix)
Out[11]:
In [13]:
# Find the maximum element in each column
np.max(matrix, axis=0)
Out[13]:
In [14]:
# Find the maximum element in each row
np.max(matrix, axis=1)
Out[14]: