The output of result are 3 arrays that are 2 dimensional with lengths that are getting decremented by one. I want to write a code that gets the ending index value last_incs, max value maxs and the minimum values mins. It should iterate through all the rows of each of the 2nd dimensional array, for example the result output for [-3,-1,-2,1] is array([array([ 0., 0., 0., 25.]),array([ 0,0, 33.33333333]), array([ 0., 50.]),array([100.])], dtype=object). The maximum values corresponding to each of these sub arrays are as follows: [25.0, 33.33333333333333, 50.0, 100.0] which is shown in the Expected Outputs below in Max:. How would I be able to do this?
import numpy as np
def run(*args):
result = np.array([np.array([((arr[i:] > 0).cumsum()/ np.arange(1, len(arr[i:])+1) * 100) for i in range(len(arr))],dtype=object) for arr in args], dtype=object)
#print(result)
last_inc = result[-1]
maxs = np.max(result)
mins = np.min(result)
run(np.array([12,12,-3,-1,2,1]), np.array([-3,-1,-2,1]), np.array([12,-12]))
Expected Output:
last incs: [array([66.66666666666666, 60.0, 50.0, 66.66666666666666, 100.0, 100.0],
dtype=object)
array([25.0, 33.33333333333333, 50.0, 100.0], dtype=object)
array([50.0, 0.0], dtype=object)]]
mins: [array([50.0, 33.33333333333333, 0.0, 0.0, 100.0, 100.0], dtype=object)
array([0.0, 0.0, 0.0, 100.0], dtype=object)
array([50.0, 0.0], dtype=object)]
maxs: [array([100.0, 100.0, 50.0, 66.66666666666666, 100.0, 100.0], dtype=object)
array([25.0, 33.33333333333333, 50.0, 100.0], dtype=object)
array([100.0, 0.0], dtype=object)]