jeudi 19 mars 2020

Creating a new array by comparing data from other arrays in Python

I currently have 3 arrays (36 x 36), and I now want to create a forth that compares the original three arrays and plots a set value depending on which array has largest value in said cell. The easiest way I can think to explain this is as follows.

Say I have the arrays;

a = [10,20,30]
    [15,20,18]

b = [0,10,70] 
    [36,67,9]

c = [0,50,20]
    [100,4,45] 

I want to create a new array that will plot 1 when 'a' is has the largest value, 2 when b is largest and 3 when c has the largest value.

So the new array should look something like this;

new_array = [1,3,2]
            [3,2,3]

I know this is probably a very simple loop but I am not very proficient in Python and could use a hand.

Aucun commentaire:

Enregistrer un commentaire