python 出现KeyError: [Open] not in index
#!/usr/bin/env python# -*-coding: UTF-8 -*-
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
directory = 'C:\\python\\mp'
filenames = os.listdir(directory)
print(filenames)
all_data = np.zeros((len(filenames),1056),dtype = np.float32)
for i in range(len(filenames)):
filename = filenames[i]
print(i)
print(filename)
data=pd.read_csv(directory+'/'+filename)
vars = ['Open']
data = data[vars]
data = np.array(data)
data = np.transpose(data)
data = data[0]
data = data[::-1]
all_data[i] = data
print(all_data.shape)
np.save('data',all_data)
运行了这段代码最后出现这种情况
新手刚刚学python!在网上查了好几天的资料了,都没有找到解决的方法,所以才来问问各位大神,该如何解决这个问题