title: Group by max or min in a numpy array
body: <p>I have two equal-length 1D numpy arrays, <code>id</code> and <code>data</code>, where <code>id</code> is a sequence of repeating, ordered integers that define sub-windows on <code>data</code>. For example:</p>
  <pre><code>id  data
  1     2
  1     7
  1     3
  2     8
  2     9
  2    10
  3     1
  3   -10
  </code></pre>
  <p>I would like to aggregate <code>data</code> by grouping on <code>id</code> and taking either the max or the min.</p>
  <p>In SQL, this would be a typical aggregation query like <code>SELECT MAX(data) FROM tablename GROUP BY id ORDER BY id</code>.</p>
  <p>Is there a way I can avoid Python loops and do this in a vectorized manner?</p>