title: Backward Elimination: 'numpy.ndarray' object has no attribute 'columns'
body: <p>I am running a while loop for back-ward elimination that will remove/ iteratively remove the attribute with the largest value (suggestion: use while loop with the p value &lt; 0.05)</p>
  
  <pre><code>thefile=input("Enter filename:")
  separator=input("Enter symbol of separator (comma, semicolon etc):")
  targetvar=input("Enter name of target variable for prediction "
                  "(note: this is case sensitive): ") # MEDV for Boston.csv
  
  # Test with boston.csv and other CSVs
  
  # Load Dataset
  dataframe=pd.read_csv(thefile,sep=separator)
  </code></pre>
  
  <pre><code># Show first few data points of the dataset
  print("This is the preview of the loaded data:")
  df = pd.read_csv(thefile,sep=separator)
  X = dataframe.loc[:,dataframe.columns != targetvar].values
  y = dataframe.iloc[:,targetvarloc].values
  df.head()
  </code></pre>
  
  <pre><code>#Backward Elimination
  cols = list(X.columns)
  pmax = 1
  while (len(cols)&gt;0):
      p= []
      X_1 = X[cols]
      X_1 = sm.add_constant(X_1)
      model = sm.OLS(y,X_1).fit()
      p = pd.Series(model.pvalues.values[1:],index = cols)      
      pmax = max(p)
      feature_with_p_max = p.idxmax()
      if(pmax&gt;0.05):
          cols.remove(feature_with_p_max)
      else:
          break
  selected_features_BE = cols
  print(selected_features_BE)
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>Traceback (most recent call last)
  &lt;ipython-input-96-3f41adb6e314&gt; in &lt;module&gt;()
  ----&gt; 1 cols = list(X.columns)
        2 pmax = 1
        3 while (len(cols)&gt;0):
        4     p= []
        5     X_1 = X[cols]
  
  AttributeError: 'numpy.ndarray' object has no attribute 'columns'
  </code></pre>