title: Python KeyError: 'column name'
body: <p>I have the data file which looks like this -</p>
  
  <pre><code>[Table 1]
  Terms         Author        Frequency
  Hepatitis     Christopher   2
  Acid          Subrata       1
  Acid          Kal           3
  Kinase        Pramod        31
  Kinase        Steve         5
  Kinase        Sharon        10
  Acid          Rob           5
  Acid          Christopher   2
  Hepatitis     Sharon        3
  </code></pre>
  
  <p>which I want to convert in a frequency matrix like this -</p>
  
  <pre><code>Terms       Christopher     Subrata   Kal    Pramod     Steve    Sharon    Rob      
  Hepatitis       2              0       0       0          0         3        0
  Acid            2              0       3       0          0         0        5
  Kinase          0              0       0       31         5         10       0
  </code></pre>
  
  <p>Now I have figured out how to do that and I am using this code for that -</p>
  
  <pre><code> a = pd.read_csv("C:\\Users\\robert\\Desktop\\Python Project\\Publications Data\\New Merged Title Terms Corrected\\Python generated file\\Terms_Frequency_File.csv")
   b = a.groupby(['Terms']).apply(lambda x:x.set_index(['Terms','Author']).unstack()['Frequency'])   
  </code></pre>
  
  <p>and this worked absolutely fine till yesterday but today I generated the [Table 1] data again as I had to add one additional author to the data and trying to make a frequency matrix again like in [Table 2] but it's giving me this silly error - </p>
  
  <pre><code>KeyError: 'Terms'
  </code></pre>
  
  <p>I am pretty sure this has to do something with the index column in the dataframe or some white space issues in the index column(in this case 'Terms' column). 
  I tried to read several answers on this like this - <a href="https://stackoverflow.com/questions/48640677/keyerror-column-name">KeyError: &#39;column_name&#39;</a> and this - <a href="https://stackoverflow.com/questions/35831496/key-error-when-selecting-columns-in-pandas-dataframe-after-read-csv">Key error when selecting columns in pandas dataframe after read_csv</a> and tried those methods but these aren't helping.</p>
  
  <p>Any help on this will be much appreciated! Thanks much!</p>