I am trying to get the max daily temperatures from a CSV file containing the date and temperature (temperature value for every minute of each day). The period spans 6 months and I need the max temperature for each day of the 6 months.
I have two lines of thought on how I could do this:
1: I figured I can use a dictionary with the key as the date (for example, '10/30/18') and the value as a list of the temperatures for that day.
I would need to loop through each row and add the temperature to each corresponding day.
Here's my start but not sure if I am approaching this in the best way
dates={}
for row in reader:
if row[0] in dates:
dates[row[0]].append([float(row[2])])
else:
tempvalues=[]
tempvalues.append(float(row[2]))
dates.update({row[0]:tempvalues})
print(dates)
2: I could use the date as the key again, but only update the value of the temperature if it is greater than the previous value. But I am not sure how to put this sort of if statement in a dictionary loop.