title: Lookup table using 2 columns to identify rows
body: <p>I have a numpy lookup table of xy coordinates, where columns 0=xa, 1=ya, 2=xb, 3=yb. I'm trying to use xa and ya (cols 0 &amp; 1) to act as the pair of elements that enable the looking up of xb and yb (cols 2 &amp; 3), which are the actual xy coordinates I want to use.</p>
  
  <pre><code>lookup=
  [[0,    0,  0,      0]
  [2,     0,  1.98,   -0.01]
  [4,     0,  3.99,   -0.01]
  [6,     0,  6.03,   -0.01]
  [8,     0,  8.02,   -0.03]
  [10,    0,  9.98,   -0.01]
  [12,    0,  11.99,  0]
  [14,    0,  13.99,  0]
  [0,     1,  -0.03,  0.88]
  [2,     1,  1.95,   0.86]
  [4,     1,  3.97,   0.85]
  [6,     1,  5.97,   0.87]
  [8,     1,  7.96,   0.86]
  [10,    1,  9.95,   0.92]
  [12,    1,  11.95,  0.92]
  [14,    1,  13.97,  0.87]]
  </code></pre>
  
  <p>I have a table with data that has x and y locations in the format xa ya, that I wish to to change to xb yb using the lookup table:</p>
  
  <pre><code>gridloc=
  [[6,    0]
   [8,    0]
   [8,    0]
   [10,   0]
   [8,    1]
   [10,   1]
   [12,   1]
   [14,   1]
  </code></pre>
  
  <p>So I want the result to be this:</p>
  
  <pre><code>newloc=
  [[6.03,   -0.01]
   [8.02,   -0.03]
   [8.02,   -0.03]
   [9.98,   -0.01]
   [7.96,   0.86]
   [9.95,   0.92]
   [11.95,  0.92]
   [13.97,  0.87]]
  </code></pre>
  
  <p>I've tried using this to try to create a dictionary, but I get an error:</p>
  
  <pre><code>mapping = dict(zip(lookup[:,0:2], range(len(lookup))))
  
  Traceback (most recent call last):
  
    File "&lt;ipython-input-12-528fb6616ce0&gt;", line 1, in &lt;module&gt;
      mapping = dict(zip(lookup[:,0:2], range(len(lookup))))
  
  TypeError: unhashable type: 'numpy.ndarray'
  </code></pre>
  
  <p>Does anyone have any advice, please? Should my tables be in numpy in the first place? Is dict the way to solve the problem?</p>