-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsitka_highs.py
More file actions
38 lines (30 loc) · 1.06 KB
/
Copy pathsitka_highs.py
File metadata and controls
38 lines (30 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from pathlib import Path
import csv
import seaborn as sns
from datetime import datetime
import matplotlib.pyplot as plt
path = Path ('weather_data/sitka_weather_07-2021_simple.csv')
lines = path.read_text().splitlines()
reader = csv.reader(lines)
header_row = next(reader)
# for index, column_header in enumerate(header_row):#the enumarate function returns the index and the value as it loops through a list.
# print(index, column_header)
#Extract high temparatures
dates,highs =[], []# an epmty lost is formed called highs
for row in reader:
current_date = datetime.strptime(row[2], '%Y-%m-%d')
high = int (row[4])#showing the position of the data in the row
dates.append(current_date)
highs.append(high)
print(highs)
#plot the high temparatures
sns.set_style('darkgrid')
fig,ax = plt.subplots()
ax.plot(dates,highs,c = 'blue')
#format the plot
ax.set_title("Daily High Temperatures, July 2021",fontsize = 24)
ax.set_xlabel('',fontsize = 16)
fig.autofmt_xdate()
ax.set_ylabel('Temeprature(f)',fontsize = 16)
ax.tick_params(labelsize = 16)
plt.show()