我試圖創建一個數組,我有風和需求的數組平均每隔15分鐘一天的時間間隔。我想在365天中的每一天將其變成日常平均值。這是我到目前爲止有:推廣Python中的方法
dailyAvg = [] # this creates the initial empty array for method below
def createDailyAvg(p): # The method
i = 0
while i < 35140: # I have 35140 data points in my array
dailyAvg.append(np.mean(p[i:i+95])) #Creates the avg of the 96, 15 minute avg
i += 95
return dailyAvg
dailyAvgWind = createDailyAvg(Wind) # Wind is the array of 15 minute avg's.
dailyAvgDemand = createDailyAvg(M) # M is the array of demand avg's
到目前爲止,我可以,如果我寫這兩次完成這件事,但是這不是良好的編程。我想弄清楚如何在兩個數據集上使用這一個方法。謝謝。