首页 > 解决方案 > IndexError,Python 绘图

问题描述

import csv
import os
from matplotlib import pyplot as plt
os.chdir('C:\\Users\\alpha\\Desktop\\sitka')
filename = 'sitka_weather_history.csv'
with open(filename) as f:
    reader=csv.reader(f)
    header_row = next(reader)
    highs=[]
    for row in reader:
        high=int(row[1])
        highs.append(row[1])


fig= plt.figure(dpi=123, figsize=(10, 6))
plt.plot(highs)
plt.show()

我的错误信息显示

IndexError:列表索引超出范围

我不确定为什么会收到此错误以及我做错了什么,如果有人可以告诉我。我会很感激!

编辑 下面是 csv 的屏幕截图 .csv 屏幕截图

标签: pythonexcelplot

解决方案


推荐阅读