title: Why does the error 'The above exception was the direct cause of the following exception:' come up on Python
body: <p>I am trying to get my CSV processed with nlargest and I've run into this error. Any reasons as to why it could be? I'm trying to get my head around it but it just doesn't seem to go away.</p>
  <pre><code>import pandas as pd
  from matplotlib import pyplot
  from sklearn.feature_selection import SelectKBest
  from sklearn.feature_selection import chi2
  from pandas import read_csv
  from pandas.plotting import scatter_matrix
  
  
  filename = '/Users/rahulparmeshwar/Documents/Algo Bots/Data/Live Data/Tester.csv'
  data = pd.read_csv(filename)
  columnname = 'Scores'
  bestfeatures = SelectKBest(k='all')
  y = data['Vol']
  X = data.drop('Open',axis=1)
  fit = bestfeatures.fit(X,y)
  dfscores = pd.DataFrame(fit.scores_)
  dfcolumns = pd.DataFrame(X.columns)
  featurescores = pd.concat([dfscores,dfcolumns],axis=1)
  print(featurescores.nlargest(5,[columnname]))
  </code></pre>
  <p>It gives me the error <code>Scores</code> the above exception was the direct cause of the following exception on the last line <code>print(featurescores.nlargest(5,[columnname]))</code>. Can someone explain to me why this is happening? I've looked around and can't seem to figure this out.</p>
  <p>EDIT: Full Error Stack:</p>
  <p><code>Exception has occurred: KeyError 'Scores'</code></p>
  <p>The above exception was the direct cause of the following exception:</p>
  <p><code>File &quot;C:\Users\mattr\OneDrive\Documents\Python AI\AI.py&quot;, line 19, in &lt;module&gt; print(featurescores.nlargest(2,'Scores'))</code></p>