I read strings from a file that looked like this:
date,temperature
0101, 55
0101, 43
0101, 22
0102, 12
0102, 32
0103, 56
0104, 99
and converted them into 2 lists:
date = [0101, 0101, 0101, 0102, 0102, 0103, 0104]
temperature = [55, 43, 22, 12, 32, 56, 99]
my final goal is to get an output where i have the maximum temperature per day, so I think the first step would be to create a dictionary where I assign the day as the key and the temperatures as the values:
datetemperature = {0101: [55,43,22], 0102: [12, 32], 0103: [56], 0104: [99]}
I tried iterating, but then I only get one value for the temperature. Zip does not really work as I cannot get the correct temperatures and dates together. Is there a way to solve this problem without importing pandas or numpy?
Here is what I have tried so far, however I find it hard to grasp my mind around how I should approach this problem
stations = []
days = []
temperatures = []
singledays = []
singlestations = []
singletemps = []
stationtemp = {}
for line in Lines:
(station, day, ac, ad, af, ag, ah, aj, temp, al, ae, ar, at, ay, au, ai, alc, ap, ax, av, an) = line.strip().split(',')
stations.append(station)
days.append(day)
temperatures.append(temp)
for day in days:
if day in singledays:
continue
else:
singledays.append(day)
for station in stations:
if station in singlestations:
continue
else:
singlestations.append(station)
stationtemp = dict(zip(stations, temperatures))