title: Python - Pandas - DataFrame reduce rows
body: <p>I have a DataFrame like so:</p>
  
  <pre><code>ind  col1 col2
  1    12   string1  ...
  2    23   string2 ...
  3    34   string1 ...
  4    13   string2 ...
  5    17   string3 ...
  ...  ...  ...     ...
  </code></pre>
  
  <p>I want to collapse the DataFrame so that col2 will be unique. In col1 (and all the other numerical columns), I want to put the median of all the values where col2 was equal.</p>
  
  <p>I know I can extract df[df["col2"] == "stringN"], calculate the medians and build a new DataFrame, but is there a more elegant/pythonic way to do this?</p>