May-13-2022, 01:00 PM
I hope I can explain my current problem in a understandable way (besides from the possible confusing title
):
I need to replace some elements of Array 1 with corresponding elements from Array 2, depending on what Array 3 indicates by its input (because it is based on a dropdown selection in excel) but I fail to find a proper formulation of the function that would do this.
Example:
Target Array / Array 1:
I already tried several ways to interpret the Input Array and then iterate over the target array, but there was no succesful attempts so far. Maybe you got an idea.
Thanks in advance!

I need to replace some elements of Array 1 with corresponding elements from Array 2, depending on what Array 3 indicates by its input (because it is based on a dropdown selection in excel) but I fail to find a proper formulation of the function that would do this.
Example:
Target Array / Array 1:
array([[0.05, 0.07 , 0.04, 0.03, 0.05, 0.72], [0.08, 0.083, 0.40 , 0.038, 0.05, 0.70], [0.40, 0.17, 0.07, 0.04, 0.03, 0.31], [0.16, 0.14, 0.08, 0.40, 0.08, 0.40]])Array for replacements / Array 2:
array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])Input Array / Array 3:
array(['No change', 'Change second element to 1', 'Change first element to 1', 'Change fourth element to 1'], dtype='<U27')Desired Output:
array([[0.05, 0.07 , 0.04, 0.03, 0.05, 0.72], [0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1]])So basically everytime the input Array 3 says "Change x element", the corresponding element of Array 1 should be replaced with the row of Array 2 so that one value becomes 1 an all others 0.
I already tried several ways to interpret the Input Array and then iterate over the target array, but there was no succesful attempts so far. Maybe you got an idea.

Thanks in advance!