title: Condition is ignored using .where() in Pandas
body: <p>I'm trying to calculate the Bonus Pay given to our Courier's based on their <code>Success Rate</code> which is based off the number of <code>Eligible</code> orders they've successfully delivered.</p>
  <p>Here's my code:</p>
  <pre><code>from openpyxl import load_workbook
  import pandas as pd
  
  df = pd.read_excel(r'path\filename.xlsx')
  
  
  df['DeliveredAt'] = pd.to_datetime(df['DeliveredAt'].astype(str))
  
  df['Date'] = df['DeliveredAt'].dt.strftime('%d/%m/%y')
  
  df['Total Orders'] = df['OrderNumber']
  
  df['Total Orders'] = 1
  
  df['Eligible'] = df['DeliveryOnTime'].isin([&quot;On-time&quot;, &quot;Early&quot;])
  
  df['Success Rate'] = (df['Eligible']/df['Total Orders'])*100
  
  df['Bonus'] = df['Eligible'].mul(1.2).where(df['Success Rate'] &gt;= 95)
  
  per_day = df.groupby(['Date', 'Courier']).agg({'Success Rate': 'mean', 'Total Orders': 'count', 'Eligible': 'sum', 'Incentive': 'sum'})
  
  per_courier = df.groupby('Courier').agg({'Total Orders': 'count', 'Incentive': 'sum'})
  </code></pre>
  <p>I'm having issues with</p>
  <pre><code>df['Bonus'] = df['Eligible'].mul(1.2).where(df['Success Rate'] &gt;= 95)
  </code></pre>
  <p>It seems to ignore the condition that <code>Success Rate</code> has to be over 95 for it to qualify for a Bonus. Right now, each row has a Bonus pay which is calculated from the number of <code>Eligible</code> * 1.2 regardless of the success rate value.</p>
  <p><strong>Sample Data:</strong></p>
  <pre><code>data = {'ID': [1, 1, 1, 2, 2, 3, 4, 5, 5],
           'DeliveryOnTime': [&quot;On-time&quot;, &quot;Late&quot;, &quot;Early&quot;, &quot;On-time&quot;, &quot;On-time&quot;, &quot;Late&quot;, &quot;Early&quot;, &quot;Early&quot;, &quot;Late&quot;],
        }
  
  df = pd.DataFrame(data)
  
  #For the sake of example data, the count of `DeliveryOnTime` will be the total number of orders. 
  df['Total Orders'] = df['DeliveryOnTime'].count() 
  df['Eligible'] = df['DeliveryOnTime'].isin([&quot;On-time&quot;, &quot;Early&quot;])
  df['Success Rate'] = (df['Eligible']/df['Total Orders'])*100
  df['Bonus'] = df['Eligible'].mul(1.2).where(df['Success Rate'] &gt;= 95)
  </code></pre>
  <p><strong>Current Output</strong></p>
  <pre><code>    ID       Eligible      Total Orders    Success Rate   Bonus
       1           2              3            66.66         2.4
       2           2              2             100          2.4
       3           0              1              0            0
       4           1              1             100          1.2
       5           1              2              50          1.2
  </code></pre>
  <p>This is wrong as ID 1 and 5 should not have any <code>Bonus</code> at all with the <code>Success Rate</code> being lower than 95.</p>
  <p><strong>Expected Output</strong></p>
  <pre><code>ID       Eligible     Total Orders    Success Rate    Bonus
   1           2              3            66.66          0
   2           2              2             100          2.4
   3           0              1              0            0
   4           1              1             100          1.2
   5           1              2              50           0
  </code></pre>
  <p>I'm not sure if it's something I have to change in the <code>Per_day</code> or <code>Per_courier</code> section of the <code>.groupby()</code> as that seems to be where most of my issues have occurred when writing this code.</p>
  <p>Thanks</p>