title: AttributeError: 'float' object has no attribute 'shape' when using linregress
body: <p>I want to use <code>LinearRegression</code> and <code>linregress</code> to caculate <code>Intercept</code>,<code>X_Variable_1</code>,<code>R_Square</code>,<code>Significance_F</code> just like regression analysis in Excel.</p>
  
  <p>When I use this code to do it, there is no mistake.</p>
  
  <pre><code>from sklearn.linear_model import LinearRegression
  import pandas as pd
  import numpy as np
  from scipy.stats import linregress
  from decimal import *
  
  def calculate_parameters():
      list_a=[['2018', '3', 'aa', 'aa', 93,1884.7746222667, 165.36153386251098], ['2018', '3', 'bb', 'bb', 62, 665.6392779848, 125.30386609565328], ['2018', '3', 'cc', 'cc', 89, 580.2259903521, 160.19280253775514]]
      df = pd.DataFrame(list_a)
      X = df.iloc[:, 5]
      y = df.iloc[:, 6]
      X1 = X.values.reshape(-1, 1)
      y1 = y.values.reshape(-1, 1)
      clf = LinearRegression()
      clf.fit(X1, y1)
      yhat = clf.predict(X1)
      para_Intercept = clf.intercept_[0]
      para_X_Variable_1 = clf.coef_[0][0]
      SS_Residual = sum((y1 - yhat) ** 2)
      SS_Total = sum((y1 - np.mean(y1)) ** 2)
      para_R_Square = 1 - (float(SS_Residual)) / SS_Total
      adjusted_r_squared = 1 - (1 - para_R_Square) * (len(y1) - 1) / (len(y1) - X1.shape[1] - 1)
      para_a = linregress(X, y)
      para_Significance_F = para_a[3]
      print("Intercept:"+str(para_Intercept))
      print("X_Variable_1:"+str(para_X_Variable_1))
      print("R_Square:" + str(para_R_Square[0]))
      print("Significance_F:" + str(para_Significance_F))
  
  if __name__ == "__main__":
      calculate_parameters()
  </code></pre>
  
  <p>The output is:</p>
  
  <blockquote>
    <p>Intercept:133.10871357512195</p>
    
    <p>X_Variable_1:0.016460552337949654</p>
    
    <p>R_Square:0.3039426453800934</p>
    
    <p>Significance_F:0.6282563718649847</p>
  </blockquote>
  
  <p>But in fact,<code>list_a</code> likes this:</p>
  
  <pre><code>list_a = [['2018', '3', 'aa', 'aa', 93, Decimal('1884.7746222667'), 165.36153386251098],
            ['2018', '3', 'bb', 'bb', 62, Decimal('665.6392779848'), 125.30386609565328],
            ['2018', '3', 'cc', 'cc', 89, Decimal('580.2259903521'), 160.19280253775514]]
  </code></pre>
  
  <p>The 6th column is decimal type.</p>
  
  <p>When I change <code>list_a</code>,likes this:</p>
  
  <pre><code>from sklearn.linear_model import LinearRegression
  import pandas as pd
  import numpy as np
  from scipy.stats import linregress
  from decimal import *
  
  def calculate_parameters():
      # list_a=[['2018', '3', 'aa', 'aa', 93,1884.7746222667, 165.36153386251098], ['2018', '3', 'bb', 'bb', 62, 665.6392779848, 125.30386609565328], ['2018', '3', 'cc', 'cc', 89, 580.2259903521, 160.19280253775514]]
      list_a=[['2018', '3', 'aa', 'aa', 93,Decimal('1884.7746222667'), 165.36153386251098], ['2018', '3', 'bb', 'bb', 62, Decimal('665.6392779848'), 125.30386609565328], ['2018', '3', 'cc', 'cc', 89, Decimal('580.2259903521'), 160.19280253775514]]
      df = pd.DataFrame(list_a)
      X = df.iloc[:, 5]
      y = df.iloc[:, 6]
      X1 = X.values.reshape(-1, 1)
      y1 = y.values.reshape(-1, 1)
      clf = LinearRegression()
      clf.fit(X1, y1)
      yhat = clf.predict(X1)
      para_Intercept = clf.intercept_[0]
      para_X_Variable_1 = clf.coef_[0][0]
      SS_Residual = sum((y1 - yhat) ** 2)
      SS_Total = sum((y1 - np.mean(y1)) ** 2)
      para_R_Square = 1 - (float(SS_Residual)) / SS_Total
      adjusted_r_squared = 1 - (1 - para_R_Square) * (len(y1) - 1) / (len(y1) - X1.shape[1] - 1)
      para_a = linregress(X, y)
      para_Significance_F = para_a[3]
      print("Intercept:"+str(para_Intercept))
      print("X_Variable_1:"+str(para_X_Variable_1))
      print("R_Square:" + str(para_R_Square[0]))
      print("Significance_F:" + str(para_Significance_F))
  
  if __name__ == "__main__":
      calculate_parameters()
  </code></pre>
  
  <p>The error is:</p>
  
  <blockquote>
    <p>Traceback (most recent call last):</p>
    
    <p>File "E:/test_opencv/MyTest.py", line 32, in 
        calculate_parameters()</p>
    
    <p>File "E:/test_opencv/MyTest.py", line 24, in calculate_parameters
        para_a = linregress(X, y)</p>
    
    <p>File "E:\Anaconda3\lib\site-packages\scipy\stats_stats_mstats_common.py", line 79, in linregress
        ssxm, ssxym, ssyxm, ssym = np.cov(x, y, bias=1).flat</p>
    
    <p>File "E:\Anaconda3\lib\site-packages\numpy\lib\function_base.py", line 3085, in cov
        avg, w_sum = average(X, axis=1, weights=w, returned=True)</p>
    
    <p>File "E:\Anaconda3\lib\site-packages\numpy\lib\function_base.py", line 1163, in average
        if scl.shape != avg.shape:</p>
    
    <p>AttributeError: 'float' object has no attribute 'shape'</p>
  </blockquote>
  
  <p>How to fix the error?</p>