-
Notifications
You must be signed in to change notification settings - Fork 0
/
Death_valley_1.py
51 lines (36 loc) · 1.15 KB
/
Death_valley_1.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
import csv
from datetime import datetime
open_file = open("death_valley_2018_simple.csv", "r")
csv_file = csv.reader(open_file, delimiter = ",")
header_row = next(csv_file)
print(header_row)
for index, column_header in enumerate(header_row):
print(index, column_header)
highs = []
dates = []
lows = []
x = datetime.strptime('2018-07-01', '%Y-%m-%d')
print(x)
for row in csv_file:
try:
high = int(row[4])
low = int(row[5])
the_date = datetime.strptime(row[2], '%Y-%m-%d')
except ValueError:
print(f"Missing data for {the_date}")
else:
highs.append(high)
lows.append(low)
dates.append(the_date)
print(highs)
import matplotlib.pyplot as plt
fig = plt.figure()
plt.plot(dates, highs, c= "red", alpha = 0.5)
plt.plot(dates, lows, c= "blue", alpha = 0.5)
plt.title("Daily Low and high Temperatures - 2018\nDeath Valley", fontsize = 16)
plt.xlabel("")
plt.fill_between(dates, highs, lows, facecolor = 'blue', alpha = 0.1)
plt.ylabel("Temperature (F)", fontsize = 16)
plt.tick_params(axis = "both", labelsize = 16)
fig.autofmt_xdate()
plt.show()