1
我想利用numpy的從下方陣列計算每個季度的一組值的平均值:如何按季度分組並使用numpy從數組中計算平均值?
Data = [{'date':'2015-01-01',value:5},{'date':'2015-02-01',value:6},{'date':'2015-03-01',value:7},{'date':'2015-04-01',value:8},{'date':'2015-05-01',value:9},{'date':'2015-06-01',value:10},{'date':'2015-07-01',value:11},{'date':'2015-08-01',value:12}]
我想結果告訴我下面的:
- 對於Q1-15,平均爲6
- 對於Q2-15,平均爲9
- 對於Q3-15,平均爲11.5
基於this stackoverflow question,我已經試過以下:
np = Data #I'm not sure how to read in data into numpy from an array in my structure
np.resample('Q',how='mean') #I'm not sure if using 'Q' would group this by quarter
檢查大熊貓。你鏈接到的問題使用熊貓。 – dbliss