我的数据集是
import sys
sys.path.append('GM/code')
inputfile1 = 'data.csv'
inputfile2 = 'green.csv'
new_reg_data = pd.read_csv(inputfile1)
data1 = pd.read_csv(inputfile2)
new_reg_data.index = range(2005, 2020)
new_reg_data.loc[2020] = None
new_reg_data.loc[2021] = None
cols = ['y','x1','x2','x3','x4','x5']//错误KeyError: 'y'
for i in cols:
f = GM11(new_reg_data.loc[range(2005,2020),i].as_matrix())[0]
这里是构建灰色预测模型,但是书上就是这么构建的,不懂为什么出错
好像excel创建的文件会出现这个问题,检查下是否是 UTF-8编码或者换一个软件来编辑csv文件如Sublime Text