how to get maximum value for each subset of a numpy splitted array?

  arrays, numpy, python

I am trying to get the maximum value for each sub_array of an numpy array that was split. The sub_arrays have different sizes. Using np.max or np.amax, i.e. no cycles.

I tried:

sub_eta = np.split(eta, zero_down_crossings) 
sub_eta = np.array(sub_eta)
max_values = np.max(sub_eta)

I get this error

ValueError: operands could not be broadcast together with shapes

It only works if all sub_arrays have the same dimension.

Source: Python Questions

LEAVE A COMMENT