从csv中读取7月高温天气数据示例1
7月sitka天气数据下载
import csv
from matplotlib import pyplot as plt
from datetime import datetime
filename = 'sitka_weather_07-2014.csv'
with open(filename) as f:
reader = csv.reader(f)
header_row = next(reader)
# print(header_row)
# for index, column_header in enumerate(header_row):
# print(index, column_header)
# get the highest temperature and plot it in the graph
dates = []
highs = []
for row in reader:
current_date = datetime.strptime(row[0], "%Y-%m-%d")
dates.append(current_date)
high = int(row[1]) # if without the "int", the output would all be char
highs.append(high)
fig = plt.figure(figsize=(10, 6))
plt.plot(dates, highs, c='red')
plt.title("Daily high temperatures, July 2014", fontsize=24