title: How to groupby and calculate new field with python pandas?
body: <p>I'd like to group by a specific column within a data frame called 'Fruit' and calculate the percentage of that particular fruit that are 'Good'</p>
  <p>See below for my initial dataframe</p>
  <pre><code>import pandas as pd
  df = pd.DataFrame({'Fruit': ['Apple','Apple','Banana'], 'Condition': ['Good','Bad','Good']})
  </code></pre>
  <p>Dataframe</p>
  <pre><code>    Fruit   Condition
  0   Apple   Good
  1   Apple   Bad
  2   Banana  Good
  </code></pre>
  <p>See below for my desired output data frame</p>
  <pre><code>    Fruit   Percentage
  0   Apple   50%
  1   Banana  100%
  </code></pre>
  <p>Note: Because there is 1 &quot;Good&quot; Apple and 1 &quot;Bad&quot; Apple, the percentage of Good Apples is 50%.</p>
  <p>See below for my attempt which is overwriting all the columns</p>
  <pre><code>groupedDF = df.groupby('Fruit')
  groupedDF.apply(lambda x: x[(x['Condition'] == 'Good')].count()/x.count())
  </code></pre>
  <p>See below for resulting table, which seems to calculate percentage but within existing columns instead of new column:</p>
  <pre><code>        Fruit Condition
  Fruit       
  Apple   0.5 0.5
  Banana  1.0 1.0
  </code></pre>