0

I'm new to python and this site, so excuse me in advance for my poor style of asking and formatting a question:

Given a numpy array that consists of x rows and y columns, where the elements are values like this:

 x=       1 2 3 4 5
          5 1 7 2 0.5   y=1
          2 3 1 5 6     y=2

The result I want is: (5,3,7,5,6)

Which command allows me to receive a row/an array of those maximum values?

Thanks !

GBlodgett
  • 12,704
  • 4
  • 31
  • 45
Dorian IL
  • 199
  • 2
  • 11

1 Answers1

1

x.max(axis=0)

The axis keyword specifies the dimension of the array that will be collapsed, rather than the dimension that will be returned. So specifying axis=0 means that the first axis will be collapsed: for two-dimensional arrays, this means that values within each column will be aggregated.

Taken from here.

nemanja228
  • 556
  • 2
  • 16