title: Drop nan rows unless string value in separate column - Pandas
body: <p>I want to drop rows containing <code>NaN</code> values except if a separate column contains a specific string. Using the <code>df</code> below, I want to drop rows if <code>NaN</code> in <code>Code2, Code3</code> unless the string A is in <code>Code1</code>.</p>
  
  <pre><code>df = pd.DataFrame({   
          'Code1' : ['A','A','B','B','C','C'],    
          'Code2' : ['B',np.nan,'A','B',np.nan,'B'],    
          'Code3' : ['C',np.nan,'C','C',np.nan,'A'],                                   
          })
  
  def dropna(df, col):
  
      if col == np.nan:
          df = df.dropna()
  
      return df
  
  df = dropna(df, df['Code2'])
  </code></pre>
  
  <p>Intended Output:</p>
  
  <pre><code>  Code1 Code2 Code3
  0     A     B     C
  1     A   NaN   NaN
  2     B     A     C
  3     B     B     C
  4     C     B     A
  </code></pre>