title: Add column representing the median for each group in a pandas dataframe
body: <p>I have a pandas dataframe <code>het</code> that has the following layout:</p>
  
  <pre><code>SampleID   expr  Gene        Period  Consequence            isPTV
  HSB430    -1.23  ENSG000098  4       upstream_gene_variant  0
  HSB321    -0.02  ENSG000098  5       stop_gained            1
  HSB296     3.12  ENSG000027  4       upstream_gene_variant  0
  HSB201     1.22  ENSG000027  4       intron_variant         0
  HSB220     0.13  ENSG000013  6       intron_variant         0
  </code></pre>
  
  <p>I'm trying to organize it such that I group by the <code>Gene</code> and then get the median <code>expr</code> across all <code>SampleIDs</code> for that <code>Gene</code>. I've attempted to do this via the following:</p>
  
  <pre><code>het_grouped= het.groupby(['Gene'])['expr'].median().reset_index()
  </code></pre>
  
  <p>The <strong>problem</strong> I'm having with this is:</p>
  
  <p>1) it's getting rid of my other columns (it only results with the <code>Gene</code> and <code>expr</code> columns).</p>
  
  <p>2) the median value is replacing the original <code>expr</code> value. I'd like the <code>Median</code> to come up in a separate column.</p>
  
  <p>I tried to address 2) by doing the following, but the resulting <code>Median</code> column comes up as blank:</p>
  
  <pre><code>het["Median"]= het.groupby(['Gene'])['expr'].median()
  </code></pre>
  
  <p>Here is my <strong>expected output</strong>:</p>
  
  <pre><code>SampleID   expr  Gene        Period  Consequence           isPTV  Median
  HSB430    -1.23  ENSG000098  4       upstream_gene_variant  0    -0.625 
  HSB321    -0.02  ENSG000098  5       stop_gained            1    -0.625
  HSB296     3.12  ENSG000027  4       upstream_gene_variant  0     2.17
  HSB201     1.22  ENSG000027  4       intron_variant         0     2.17
  HSB220     0.13  ENSG000013  6       intron_variant         0     0.13
  </code></pre>