title: Keyerror when trying to do a lookup b/w two files using pandas
body: <p>I have two files, sample1.csv is a big file and sample2.csv is a subset. I simply want to create a data frame has all columns of sample1.csv for the 'enterpriseid' from sample2.csv</p>
  <p><a href="https://i.stack.imgur.com/vKyPN.png" rel="nofollow noreferrer">Shows data from sample1.csv</a></p>
  <p><a href="https://i.stack.imgur.com/Ic8Hh.png" rel="nofollow noreferrer">Shows data from sample2.csv</a></p>
  <pre><code>    import pandas as pd 
      import numpy as np
  
      df_raw = pd.read_csv(&quot;sample1.csv&quot;,skip_blank_lines=True,error_bad_lines=False).fillna(&quot;&quot;)
  
      df_res = pd.read_csv(&quot;sample2.csv&quot;).fillna(&quot;&quot;)
      df_res_ent['enterpriseid'] = df_res[&quot;enterpriseid&quot;]
      df_f = df_raw[df_res_ent['enterpriseid']]
      df_f
  
  **Below is the error**
  
  ---------------------------------------------------------------------------
  KeyError                                  Traceback (most recent call last)
  &lt;ipython-input-71-69c3a17d981e&gt; in &lt;module&gt;
        1 #df = pd.merge(df_res_ent,df_raw,on ='enterpriseid',how ='inner')
  ----&gt; 2 df_f = df_raw[df_res_ent['enterpriseid']]
        3 df_f
        4 
        5 #output = df.to_csv(&quot;output.csv&quot;)
  
  ~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py in __getitem__(self, key)
     2804             if is_iterator(key):
     2805                 key = list(key)
  -&gt; 2806             indexer = self.loc._get_listlike_indexer(key, axis=1, raise_missing=True)[1]
     2807 
     2808         # take() does not accept boolean indexers
  
  ~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexing.py in _get_listlike_indexer(self, key, axis, raise_missing)
     1550             keyarr, indexer, new_indexer = ax._reindex_non_unique(keyarr)
     1551 
  -&gt; 1552         self._validate_read_indexer(
     1553             keyarr, indexer, o._get_axis_number(axis), raise_missing=raise_missing
     1554         )
  
  ~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/indexing.py in _validate_read_indexer(self, key, indexer, axis, raise_missing)
     1638             if missing == len(indexer):
     1639                 axis_name = self.obj._get_axis_name(axis)
  -&gt; 1640                 raise KeyError(f&quot;None of [{key}] are in the [{axis_name}]&quot;)
     1641 
     1642             # We (temporarily) allow for some missing keys with .loc, except in
  
  KeyError: &quot;None of [Index(['AMPR.2Y2YI0', 'AMPR.CQW0UW', 'AMPR.ICWWWE', 'AMPR.KGGAYG',\n       'AMPR.OK0MGQ', 'AMPR.OWYUS2', 'AMPR.2GQSOQ', 'AMPR.04WOYW',\n       'AMPR.W00MWS', 'AMPR.QQKUIU',\n       ...\n       '', '', '', '', '', '', '', '', '', ''],\n      dtype='object', length=14844)] are in the [columns]&quot;
  </code></pre>