title: pandas dataframe equivalent to R data.table by
body: <p>Is there in pandas data frame an equivalent to using 'by' in R data.table?</p>
  
  <p>for example in R I can do:</p>
  
  <pre><code>DT = data.table(x = c('a', 'a', 'a', 'b', 'b', 'b'), y = rnorm(6))
  DT[, z := mean(y[1:2]), by = x]
  </code></pre>
  
  <p>Is there something similar in pandas?</p>