1

Is there a function in the numpy API that finds the maximum values of an array like this?

def fun_max(array,axis=None):
    return [max(array[:i+1]) for i in range(len(array))]

a=[3,4,2,1,5]
print(fun_max(a))

output:

[3,4,4,4,5]
rafaelc
  • 57,686
  • 15
  • 58
  • 82

0 Answers0