我遇到了这么多麻烦,如果能伸出援助之手,我想知道。我正在尝试通读csv文件并提取列并绘制column_index
中列出的任何列,这实际上是提供给用户的输入并且可以更改。
以下是我的.csv文件的pastebin的link,这是我的尝试:
with open('./P14_data.csv', 'rb') as csvfile:
data = csv.reader(csvfile, delimiter=',')
#retrieves rows of data and saves it as a list of list
x = [row for row in data]
#forces list as array to type cast as int
int_x = np.array(x, int)
column_index = [1,2,3]
column_values = np.empty(0)
for col in column_index:
#loops through array
for array in range(len(int_x)):
#gets correct column number
column_values = np.append(column_values,np.array(int_x[array][col-1]))
plt.plot(column_values)
但是,当我想要3列不同的列时,这只会为所有3列绘制一行: