title: statmodels OLS giving a TypeError in python
body: <p>I am trying to fit a set of features to statsmodel's OLS linear regression model.</p>
  
  <p>I am adding a few features at a time. With the first two features, it works fine. But when I keep adding new features it gives me an error.</p>
  
  <pre><code>Traceback (most recent call last):
    File "read_xml.py", line 337, in &lt;module&gt;
      model = sm.OLS(Y, X).fit()
  ...
    File "D:\pythonprojects\testproj\test_env\lib\site-packages\statsmodels\base\data.py", line 132, in _handle_constant
      if not np.isfinite(ptp_).all():
  TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
  </code></pre>
  
  <p>So I changed the type of input using</p>
  
  <pre><code>X = X.astype(float)
  </code></pre>
  
  <p>Then a different error pops out.</p>
  
  <pre><code>Traceback (most recent call last):
    File "read_xml.py", line 339, in &lt;module&gt;
      print(model.summary())
  ...
  File "D:\pythonprojects\testproj\test_env\lib\site-packages\scipy\stats\_distn_infrastructure.py", line 1824, in sf
      place(output, (1-cond0)+np.isnan(x), self.badvalue)
  TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
  </code></pre>
  
  <p>My code looks like this.</p>
  
  <pre><code>new_df0 = pd.concat([df_lex[0], summary_df[0]], axis = 0, join = 'inner')
  new_df1 = pd.concat([df_lex[1], summary_df[1]], axis = 0, join = 'inner')
  data = pd.concat([new_df0, new_df1], axis = 1)
  print(data.shape)
  X = data.values[0:6,:]
  Y = data.values[6,:]
  Y = Y.reshape(1,88)
  X = X.T
  Y = Y.T
  X = X.astype(float)
  model = sm.OLS(Y, X).fit()
  predictions = model.predict(X)
  print(model.summary())
  </code></pre>
  
  <p>First error triggered in <code>model = sm.OLS(Y,X).fit()</code>
  Second error triggered in <code>model.summary()</code></p>
  
  <p>But with some other features, there are no errors. </p>
  
  <pre><code>new_df0 = pd.concat([df_len[0], summary_df[0]], axis = 0, join = 'inner')
  new_df1 = pd.concat([df_len[1], summary_df[1]], axis = 0, join = 'inner')
  
  data = pd.concat([new_df0, new_df1], axis = 1)
  print(data.shape)
  X = data.values[0:2,:]
  Y = data.values[2,:]
  Y = Y.reshape(1,88)
  X = X.T
  Y = Y.T
  X = X.astype(float)
  print(X.shape)
  print(Y.shape)
  
  model = sm.OLS(Y, X).fit()
  predictions = model.predict(X)
  print(model.summary())
  </code></pre>
  
  <p>It looks like when I have only two features it works. But when different 6 features added, it gives the errors. My major concern is to understand the error. Because I have read similar question related to plots in python. But this is triggered in the built-in functions, not in my code. Any suggestions to debug is highly appreciated.</p>