I have an array with size ( 61000) I want to normalize it based on this rule: Normalize the rows 0, 6, 12, 18, 24, ... (6i for i in range(1000)) based on the formulation which I provide. Dont change the values of the other rows. Here is an example:
def normalize(array):
minimum = np.expand_dims(np.min(array, axis=1), axis=1)
maximum = np.expand_dims(np.max(array, axis=1), axis=1)
return (array - minimum) / (maximum - minimum + 0.00001)
Calling with the following input doesn't work:
A = array([[15, 14, 3],
[11, 9, 9],
[16, 6, 1],
[14, 6, 9],
[ 1, 12, 2],
[ 5, 1, 2],
[13, 11, 2],
[11, 4, 1],
[11, 7, 10],
[10, 11, 16],
[ 2, 13, 4],
[12, 14, 14]])
normalize(A)
I expect the following output:
array([[0.99999917, 0.9166659 , 0. ],
[11, 9, 9],
[16, 6, 1],
[14, 6, 9],
[ 1, 12, 2],
[ 5, 1, 2],
[0.99999909, 0.81818107, 0. ]],
[11, 4, 1],
[11, 7, 10],
[10, 11, 16],
[ 2, 13, 4],
[12, 14, 14]])
array[::6] = normalize(array[::6])work? if not, could you explain more what the issue you're facing is?adefinition in the first line? that looks like it's not used anywherearray = array.astype('float'), then doarray[::6] = normalize(array[::6]).