如何解决如何修复此错误:TypeError:无法将序列乘以“float”类型的非整数
我正在运行一个代码并收到此错误:
TypeError: can't multiply sequence by non-int of type 'float'
运行此行时:
regressor_OLS = sm.OLS(endog=y,exog=X_opt).fit()
代码如下:
import numpy as np
import pandas as pd
import statsmodels.api as sma
#X = np.append(arr = np.ones((124,1)).astype(float),values = X,axis = 1)
#print(type(X))
X = sma.add_constant(X)
import statsmodels.api as sm
X_opt = np.array(X[:,[0,1,2,3,4,5,6,7,8,9]],dtype=float)
print(X_opt)
regressor_OLS = sm.OLS(endog=y,exog=X_opt).fit() # this line causing problem
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。