我有一個看起來像這樣的資料框:
type date count CLASS
A jan 456 0
A feb 121 1
A mar 333 1
B apr 123 1
B may 123 1
C jun 189 1
C jul 789 1
我想創建一個“A”型別的計數隨時間(日期)的散點圖,所以我需要使用型別、日期和計數列。
我想做這樣的事情,但我不確定如何合并計數列?
group = df.groupby('Type' == 'A')
df.plot.scatter(x = 'Year_Month', y = group)
plt.legend()
plt.show()
當我嘗試這個時,我也遇到了一個關鍵錯誤 ^
基本上,散點圖應該隨著時間的推移繪制型別 A 的計數。
謝謝你。
uj5u.com熱心網友回復:
嘗試這個:
df[df['type']=='A'].plot.scatter('date', 'count')
由于您只需要型別為的資料,因此A此處不需要 groupby。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/525778.html
