我有來自氣象站的太陽輻射記錄(每 10' 1 條記錄),作為熊貓資料框。我想生成完整資料集的熱圖,在 x 軸上,我有一天中的小時 (0-24),在一年中的每一天在 y 軸上,顏色給出了值。
我的資料框被稱為“太陽能”。我用了
solar_grouped = solar.groupby(pd.Grouper(freq='D'))
按天對資料進行分組,但是我無法每天訪問,而且我不知道如何開始繪制熱圖
uj5u.com熱心網友回復:
import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
x = data.groupby(["Day",'Hour'])["Target_Col"].mean()
mean_ = round(x.mean(),2)
x = x.unstack().fillna(mean_)
plt.figure(figsize=(len(x.columns),len(x.index)))
sns.heatmap(data=x, annot=True)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/402729.html
標籤:
上一篇:從字串火花鑄造日期
