title: Groupby with a condition on another column in pandas
body: <p>I have a dataframe where I am doing the following : </p>
  
  <pre><code>df1 = df.groupby('Date_1')['weight'].sum().reset_index(name='total_weight')
  </code></pre>
  
  <p>I am trying to aggregate the total sum of weights for a particular date. </p>
  
  <p>I want to add a condition such that it takes sum only when is_b is 1. is_b is another column where there are 2 values 0 and 1. </p>
  
  <p>Can anyone advise as to how to use the condition with groupby in pandas. </p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT</strong> </p>
  
  <p>DF</p>
  
  <pre><code>Date_1    weight isBooked
  01/09/2019  181  1
  01/09/2019  189  1
  01/09/2019  174  1
  01/09/2019  267  1
  01/09/2019  308  1
  02/09/2019  79   0
  02/09/2019  179  1
  02/09/2019  435  1
  </code></pre>
  
  <p>Note that dataframe has other columns as well, just posting the relevant fields here. </p>