title: loop through dataframe columns to do simple linear regression?
body: <pre><code>import pandas as pd
  import numpy as np
  
  from sklearn.linear_model import LinearRegression
  
  df = pd.read_excel("Book1.xlsx")
  
  for column in df:
  
      X = df["Row Labels"]
  
      Y = df[column]
      y1 =Y.values.reshape(-1,1)
      x1 =X.values.reshape(-1,1)
      regressor = LinearRegression()
      regressor.fit(x1, y1)
      y_new = []
      y_i = []
      for i in range(12,24):
          y_new.append(regressor.predict([[i]]))
          y_i.append(i)
  
      df2 = pd.DataFrame({'column':y_new})
  </code></pre>
  
  <p>i write this code to loop through the dataframe columns to do simple linear regression and put all the predicted value in dataframe. but it is predicting only the last columns value.</p>