title: Flagging NaN values based on a condition and year
body: <p>I am trying to get this requirement of flagging NaN values based on condition and particular year, below is my code:</p>
  <pre><code>import pandas as pd
  import numpy as np
  s={'Fruits':['Apple','Orange', 'Banana', 'Mango'],'month':['201401','201502','201603','201604'],'weight':[2,4,1,6],'Quant':[251,178,298,300]}
  p=pd.DataFrame(data=s)
  upper = 250
  </code></pre>
  <p>How would I be able to flag NaN values for month- <code>201603</code> and <code>201604</code> (03 and 04 are the months), if <code>upper&gt;250</code>. Basically my intention is to check if <code>Quant</code> value is greater than defined <code>upper</code> value, but for specific date i.e. 201603 and 201604.</p>
  <p>This is how the output should look like-</p>
  <pre><code>Fruits  month   weight  Quant
  0   Apple   201401  2   251.0
  1   Orange  201502  4   178.0
  2   Banana  201603  1   NaN
  3   Mango   201604  6   NaN
  </code></pre>