So far, it is easy to walk through a two-dimensional array to store the maximum value obtained while running with a particular dimension. The way. For example, I have an array:
[[2, 1, 5], [-1, -1, 4], [4, 3, 2], [2, 3, 4]] and I want the following output:
[[2, 2, 5], [-1, -1, 4] , [4, 4, 4], [2, 3, 4]] Thanks!
Easy; Use:
& gt; & Gt; & Gt; Numpy.maximum.accumulate (a, axis = 1) array ([[2, 2, 5], [-1, -1, 4], [4, 4, 4], [2, 3, 4]])
Comments
Post a Comment