title: Python - Pandas - Key Error during dropna call for specific subsets
body: <p>My goal: I wish to drop rows who have NaN in specific columns. I will allow NaN to exist on some columns but not others. 
  English Example: If value of 'detail_age' in a row is NaN, I want to remove that row.</p>
  
  <p>Here is a view of my data:</p>
  
  <pre><code>import pandas as pd
  df = pd.read_csv('allDeaths.csv', index_col=0, nrows=3, engine='python')
  print(df.shape)
  print(list(df))
  </code></pre>
  
  <p>Which outputs:</p>
  
  <pre><code>(3,15)
  ['education_1989_revision', 'education_2003_revision', 
  'education_reporting_flag', 'sex', 'detail_age', 'marital_status', 
  'current_data_year', 'injury_at_work', 'manner_of_death', 'activity_code', 
  'place_of_injury_for_causes_w00_y34_except_y06_and_y07_', '358_cause_recode', 
  '113_cause_recode', '39_cause_recode', 'race']
  </code></pre>
  
  <p>When I attempt to remove rows who's columns value is NaN with the following:</p>
  
  <pre><code>df.dropna(subset=[2,3,4,5,6,7,8,9,11,12,13,14], axis=1, inplace=True, how='any')
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "clean.py", line 10, in &lt;module&gt;
      df.dropna(subset=[2,3,4,5,6,7,8,9,11,12,13,14], axis=1, inplace=True, how='any')
    File "/usr/local/lib/python3.4/dist-packages/pandas/core/frame.py", line 3052, in dropna
      raise KeyError(list(np.compress(check, subset)))
  KeyError: [3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14]
  </code></pre>
  
  <p>Which is weird because this works:</p>
  
  <pre><code>df.dropna(subset=[2], axis=1, inplace=True, how='any')
  </code></pre>
  
  <p>But not this:</p>
  
  <pre><code>df.dropna(subset=[5], axis=1, inplace=True, how='any')
  </code></pre>
  
  <p>So there must be something wrong with certain columns or the values in those columns. Here is a peek at my data with df.head(3): </p>
  
  <p><a href="https://i.stack.imgur.com/H1pub.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/H1pub.png" alt="As image because formatting is annoying"></a></p>