2
我有這麼多麻煩,我想如果我能得到一隻手。我試圖通過csv文件讀取並提取列並繪製column_index
中列出的任何列,這些列實際上是提供給用戶的輸入並且可以更改。通過csv文件循環並繪製列?
這裏是我的.csv文件引擎收錄的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行不同:
顯示打印(int_x),印刷(column_values)結果,並打印(column_values)剛剛plt.plot()之前 – Exprator