# How to get the minimum and maximum value of a given NumPy array along the second axis?

Let’s see How to get the minimum and maximum value of a given NumPy array along the second axis. Here, the Second axis means row-wise.

We are using  numpy.amax() and numpy.amin() function of NumPy to get the minimum and maximum values of an array along the second axis respectively.

numpy.amax(): This function returns maximum of an array or maximum along axis(if mentioned).

Syntax: numpy.amax(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)

numpy.amin(): This function returns minimum of an array or minimum along axis(if mentioned).

Syntax: numpy.amin(a, axis=None, out=None, keepdims=<no value>, initial=<no value>, where=<no value>)

Now, Let’s see an example:

Example 1:

## Python3

 `# Import numpy library ` `import` `numpy as np ` ` `  `# Create a numpy array ` `arr ``=` `np.array([[``0``, ``1``], ` `                ``[``2``, ``3``]]) ` ` `  `print``(``"Given Array:\n"``, ` `     ``arr) ` ` `  `# find row-wise max values  ` `rslt1 ``=` `np.amax(arr, ``1``) ` `print``(``"\nMaximum Value:"``, ` `      ``rslt1) ` ` `  `# find row-wise min values ` `rslt2 ``=` `np.amin(arr, ``1``) ` `print``(``"\nMinimum Value:"``, ` `      ``rslt2)`

Output:

```Given Array:
[[0 1]
[2 3]]

Maximum Value: [1 3]

Minimum Value: [0 2]```

Example 2:

## Python3

 `# Import numpy library ` `import` `numpy as np ` ` `  `# Create a numpy array ` `arr ``=` `np.array([[``10``, ``34``, ``45``], ` `                ``[``22``, ``-``3``, ``46``],  ` `                ``[``33``, ``4``, ``6``]]) ` ` `  `print``(``"Given array:\n"``, ` `     ``arr) ` ` `  `# find row-wise max values  ` `rslt1 ``=` `np.amax(arr, ``1``) ` `print``(``"\nMaximum value along the second axis:"``, ` `      ``rslt1) ` ` `  `# find row-wise min values  ` `rslt2 ``=` `np.amin(arr, ``1``) ` `print``(``"\nMinimum value along the second axis:"``, ` `     ``rslt2) `

Output:

```Given array:
[[10 34 45]
[22 -3 46]
[33  4  6]]

Maximum value: [45 46 33]

Minimum value: [10 -3  4]```

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.