title: Ignore warning Pandas KeyError: value not in index
body: <p>Is there a way to suppress the pandas KeyError: '[x]' not in index? For example, if I have a data frame with columns A B C, and I call df[['A','B','C','D']], is it possible to have it just return A,B,C and ignore D if it does not exist?</p>
  
  <p>Example code</p>
  
  <pre class="lang-py prettyprint-override"><code>import pandas as pd
  import numpy as np
  
  a = np.matrix('[1,4,5];[1,2,2];[9,7,5]')
  
  df = pd.DataFrame(a,columns=['A','B','C'])
  
  df[['A','B','C','D']]
  
  </code></pre>
  
  <p>Here's the error message</p>
  
  <pre class="lang-py prettyprint-override"><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "/usr/lib/python3/dist-packages/pandas/core/frame.py", line 2133, in __getitem__
      return self._getitem_array(key)
    File "/usr/lib/python3/dist-packages/pandas/core/frame.py", line 2177, in _getitem_array
      indexer = self.loc._convert_to_indexer(key, axis=1)
    File "/usr/lib/python3/dist-packages/pandas/core/indexing.py", line 1269, in _convert_to_indexer
      .format(mask=objarr[mask]))
  KeyError: "['D'] not in index"
  </code></pre>