title: Need to collate information from array in python, by finding match values that lie in different rows
body: <p>I'm looking to collate 2 entries into one for many columns in a data array, by checking to see if several values in the two entries are the same.</p>
  
  <pre><code>0  A             [[0.0,    0.5,    2.5,    2.5]
  1  B              [0.5,    1.0,    2.0,    2.0]
  2  M              [2.5,    2.5,    0.5,    0.0]
  3  N              [2.0,    2.0,    1.0,    0.5]
  4  R              [14.3,   13.8,   13.9,   14.2]]
  </code></pre>
  
  <p>Above shows the format the array takes, with the numbering and annotation of the rows on the left. Each column in the array is one distinct measurement.</p>
  
  <p>Rows 0-3 are the x-locations along a straight line of 2 pairs of electrodes used to make a measurement (pair 1 = A &amp; B, pair 2 = M &amp; N); R is the measured resistivity when the four electrodes above it are used. As can be seen, in the 1st and 4th measurement, pair AB of measurement 1 = pair MN of measurement 4, and vice versa. The same is true of the 2nd and 3rd reading.</p>
  
  <p>What I'm trying to do is to search through the array to find each pair of measurements, then collate that into one entry. This entry would take the first measurement's electrode locations (A,B,M &amp;N), together with the first measurement's R value, but would also contain an extra row with the second measurement's R value. The result from the example above can be seen below.</p>
  
  <pre><code>0  A             [[0.0,    0.5]
  1  B              [0.5,    1.0]
  2  M              [2.5,    2.5]
  3  N              [2.0,    2.0]
  4  R1             [14.3,   13.8]
  5  R2             [13.9,   14.2]]
  </code></pre>
  
  <p>Some information that may be useful:
  The numbers are floats
  The first set of measurements (i.e. before there will be any pairs) are in the first half of the dataset. What I mean by that is if there was an array with 100 columns(equalling 100 measurements), the columns 51-100 would be the pairs of the columns 1-50. The columns 51-100 do not follow the same pattern as the columns 1-50 though (i.e. column 1 wouldn't always equal column 51 in that example).
  The electrodes do always follow the same pattern in the pair of measurements; "A" in measurement 1 will always = "M in measurement 2 in the pair, equally B = N, M = A &amp; N = B.</p>
  
  <p>I've been thinking bout how to do it, and I've thought that some kind of if statement such as the one below may be a start, but really I'm a complete novice, and this is quite a complex problem to search for an answer.</p>
  
  <pre><code>if all(A1 == M2, B1 == N2, M1 == A2, N1 == B2):
  </code></pre>
  
  <p>Any help would be really appreciated, even if it's just a pointer to wherever would be a good starting point to search for more information.</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Just to clarify, the order of R2 is liable to change for each dataset, and isn't the same as the order of R1. What I'm after doing is querying the A, B, M &amp; N values to find the pairs of readings, then adding the paired R2 reading under its corresponding R1 reading.</p>
  
  <p>Here is an example dataset that is a little larger:</p>
  
  <pre><code>#Input array
  Arr1  =
  [[0.5,  0.5,  1,    1,    1.5,  1.5,  1.5,  5,    4.5,  4.5,  3.5,  2.5,  2,    1]
   [0,    0,    0.5,  0.5,  1,    1,    0.5,  5.5,  5,    5.5,  4,    3,    2.5,  1.5]
   [1,    3.5,  2.5,  5,    2,    4.5,  4.5,  1,    1.5,  1.5,  0.5,  1,    1.5,  0.5]
   [1.5,  4,    3,    5.5,  2.5,  5,    5.5,  0.5,  1,    0.5,  0,    0.5,  1,    0]
   [14.3, 13.3, 25.1, 17.2, 19.9, 15.4, 16.1, 17.1, 15.3, 16.1, 13.4, 25.1, 19.8, 14.4]]
  
  #Output array - extra R row and half the columns
  Arr2 =
  [[0.5,  0.5,  1,    1,    1.5,  1.5,  1.5]
   [0,    0,    0.5,  0.5,  1,    1,    0.5]
   [1,    3.5,  2.5,  5,    2,    4.5,  4.5]
   [1.5,  4,    3,    5.5,  2.5,  5,    5.5]
   [14.3, 13.3, 25.1, 17.2, 19.9, 15.4, 16.1]
   [14.4, 13.4, 25.1, 17.1, 19.8, 15.3, 16.1]]
  </code></pre>