1

As I now that numpy.ndarray.max using axis argument, it should return array of maximums over that axis. But I get results as if the axes are swapped.

import numpy as np

a = np.array([[1,5,50],[89,7,14]])

a.max(axis=0)
 array([89,  7, 50])

a.max(axis=1)
array([50, 89])

Isn't these results are swapped? Since when I use axis=0, I should get the maximums per row, and when using axis=1 I should get the maximums per column. However, the results are swapped here. how could that be?

Hisham Ragheb
  • 144
  • 2
  • 10
  • 1
    Check out [Ambiguity in Pandas Dataframe / Numpy Array "axis" definition](http://stackoverflow.com/questions/25773245/ambiguity-in-pandas-dataframe-numpy-array-axis-definition) – ayhan Aug 07 '16 at 22:02

1 Answers1

0

The docs says:

If axis is an integer, then the operation is done over the given axis (for each 1-D subarray that can be created along the given axis).

so along the rows axis column vectors created and vice versa.

Ohad Eytan
  • 8,114
  • 1
  • 22
  • 31