title: How to make a column of median for each value within groups?
body: <p>I have three columns: A BatchID, UnitID, and Score.</p>
  
  <p>At the moment, the data set looks something like this:</p>
  
  <pre><code>BatchID      UnitID           Score
  A123         A123-100         0.111
  A123         A123-101         0.121
  A123         A123-102         0.101
  A123         A123-103         0.102
  B456         B456-200         0.211
  B456         B456-201         0.221
  C789         C789-001         0.199
  C789         C789-002         0.189
  C789         C789-003         0.192
  C789         C789-004         0.201
  ...          ...              ...
  </code></pre>
  
  <p>I want to add a column "median" that gets the median of the score each BATCH, and places it next to the rest of the data (repeating the same median value for each Unit in a unique Batch). Something like this:</p>
  
  <pre><code>BatchID      UnitID           Score      Median
  A123         A123-100         0.111      0.1065
  A123         A123-101         0.121      0.1065
  A123         A123-102         0.101      0.1065
  A123         A123-103         0.102      0.1065
  B456         B456-200         0.211      0.2160
  B456         B456-201         0.221      0.2160
  C789         C789-001         0.199      0.1955
  C789         C789-002         0.189      0.1955
  C789         C789-003         0.192      0.1955
  C789         C789-004         0.201      0.1955
  ...          ...              ...        ...
  </code></pre>
  
  <p>I tried groupby, among other things, but given that I don't really know how to use it in this case, that's not giving me the desired output.</p>
  
  <p>Thank you!</p>