2017-02-11 109 views
2

我想繪製具有12個月數據的數據集的時間序列。然而,數據記錄了12個月每天的每個小時。整個數據集超過8000個數據點。該數據是按以下格式帶有大量數據點的繪圖時間序列matplotlib

 Date Time Energy 
0 2014-01-01 1  1118.1 
1 2014-01-01 2  1233.2 
2 2014-01-01 3  1278.2 
.  .  .  . 
23 2014-01-01 24 1125.3 
24 2014-01-02 1  1213.3 
. .   .  . 

當我繪製像這樣

plt.plot(energy['Date'], energy['Energy']) 
plt.xlabel('Date') 
plt.ylabel('Energy') 

我得到以下輸出 time series

該圖沒有多大意義,因爲我不能觀察任何趨勢。我反而想繪製每天的平均能量。有關如何在這樣的,我觀察任何趨勢的方式繪製此時間序列中任何其他的建議是值得歡迎的

+0

這是8000? https://giphy.com/gifs/wander-over-yonder-Mra7xZQpHxNC現在我正在用2,747,418 * 2個點來爭奪一個相對較小的數據集。 – wordsforthewise

回答

3

您需要groupby與聚集mean第一:

energy = energy.groupby('Date')['Energy'].mean() 

然後Series.plot

energy.plot() 

All together:

energy.groupby('Date')['Energy'].mean().plot() 
1

IIUC:

你需要排序

energy = energy.sort_values(['Date', 'Time']) 
plt.plot(energy['Date'], energy['Wind Generation']) 
plt.xlabel('Date') 
plt.ylabel('Energy') 
plt.autofmt_xdate() 
相關問題