I have two arrays. I would like to use one of them as a reference for the second one, how can I do it? I have the following array A:
A = np.array([[1.00, 0.0, 1.03, 1.18],
[0.0, 1.58, 0.0, 7.59],
[1.00, 1.22, 1.07, 1.03]])
In addition, I have the array B:
B = np.array([[1.00, 2.00, 27.00, 10.00],
[3.00, 9.00, 6.00, 2.00],
[2.00, 6.00, 4.00, 15.00]])
I need to identify the position/location ([i,j]) of all zeros in A by column (if you pass from array to dataframe-just to clarify my point), then go to B and perform a certain operation (sum, or any other math formula) in the same [i,j]. I dont know how to it with arrays.
What I did up to now: I could solve this building a new array (C) which have i-columns (viewed as a dataframe) from A and B, then deleted rows where the first column is zero and performed the operation (in a loop sequence). I know this is not the most efficient way to do it.
I also tried changing array to dataframe (then applied loc), but I prefer to use array for data manipulation. Finally, I tried this but the following message pops up arrays used as indices must be of integer (or boolean) type
I would like to learn a new approach to my task. Thank you very much.