Jan-19-2023, 12:29 PM
I have trouble with iterating through dict_values, while unpacking the dictionary.
I have a dictionary which contains 2 arrays, a and b:
I want to scale the values of a and b on a scale of 0 to 1 range.
I wrote a function for that and want to iterate it over the arrays, and at the end, I want to get the dictionary including the arrays with values between 0 to 1.
but this function (NormalizeData) doesn't do anything.
I'd appreciate for any suggestions why my current code does not work.
I have a dictionary which contains 2 arrays, a and b:
1 2 3 4 5 6 7 8 9 10 11 |
a = np.array([[ 3 , 1 , 3 , 2 ], [ 1 , 3 , 3 , 1 ], [ 1 , 1 , 3 , 1 ], [ 1 , 2 , 2 , 3 ]]) b = np.array([[ 1 , 2 , 4 , 3 ], [ 1 , 3 , 4 , 3 ], [ 2 , 4 , 4 , 2 ], [ 2 , 2 , 2 , 4 ]]) dic = { "arr1" : a, "arr2" : b} |
I wrote a function for that and want to iterate it over the arrays, and at the end, I want to get the dictionary including the arrays with values between 0 to 1.
1 2 3 4 5 6 |
def NormalizeData(i): return (i - np.nanmin(i)) / (np.nanmax(i) - np.nanmin(i)) for i in dic.values(): NormalizeData(i) print (i) |
I'd appreciate for any suggestions why my current code does not work.