I have an array with 8760 values. I want to calculate the average for every 24 values and return the 365 average values as an array. Is this correct or is there a more simple way of doing this?
temps = data['temperature'] #Fetching temperaturedata from dictionary temps_array = np.asarray(temps) #Converting temps list to array averages = daily_mean_temp(temps_array) #Running function that calculates mean def daily_mean_temp(hourly_temp): average_temps = [x.mean() for x in np.array_split( [float(x) for x in hourly_temp], 365)] #This is a list average_temps_array = np.asarray(average_temps) #Converting from list to array return average_temps_array #return array with mean values
sum(mylist)/len(mylist)for computing the average of a list?