title: Python pandas: elegant division within dataframe
body: <p>I'm new on stackoverflow and have switched from R to python. I'm trying to do something probably not too difficult, and while I can do this by butchering, I am wondering what the most pythonic way to do it is. I am trying to divide certain values (<code>E</code> where <code>F=a</code>) in a column by values further down in the column (<code>E</code> where <code>F=b</code>) using column <code>D</code> as a lookup:</p>
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  df = pd.DataFrame({'D':[1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1], 'E':[10,20,30,40,50,100, 250, 250, 360, 567, 400],'F':['a', 'a', 'a', 'a', 'a', 'b','b', 'b', 'b', 'b', 'c']})
  print(df)
  out = pd.DataFrame({'D': [1, 2, 3, 4, 5], 'a/b': [0.1, 0.08, 0.12 , 0.1111, 0.0881]}
  print(out)
  </code></pre>
  <p>Can anyone help write this nicely?</p>