[英]Plot a pandas dataframe using matplotlib with data grouped by year/month
[英]How to plot grouped data using MatPlotLib?
我有來自 facebook 的數據,我解析了這些數據,我想使用MatPlotLib繪制一個圖。 我想在折線圖中查看我每年使用某些單詞的頻率。 我有這個數據,我想看起來像下圖,但用 MatPlotLib 而不是 Altair 繪制。 (不要擔心標題或圖例)
下面的數據可以使用 pandas 轉換為 DataFrame - pd.DataFrame(df)
df = {'word': {2: 'lol',
3: 'like',
4: 'yeah',
5: 'get',
6: 'know',
7: 'good',
8: 'ur',
9: 'ok',
10: 'haha',
11: 'man',
12: 'lol',
13: 'yeah',
14: 'like',
15: 'good',
16: 'ok',
17: 'ur',
18: 'man',
19: 'get',
20: 'know',
21: 'haha',
22: 'yeah',
23: 'lol',
24: 'man',
25: 'ok',
26: 'like',
27: 'good',
28: 'get',
29: 'ur',
30: 'know',
31: 'haha'},
'count': {2: 9,
3: 5,
4: 5,
5: 4,
6: 3,
7: 3,
8: 2,
9: 1,
10: 1,
11: 1,
12: 57,
13: 48,
14: 36,
15: 31,
16: 23,
17: 19,
18: 17,
19: 16,
20: 11,
21: 2,
22: 129,
23: 100,
24: 52,
25: 51,
26: 50,
27: 40,
28: 35,
29: 30,
30: 27,
31: 22},
'year': {2: 2010,
3: 2010,
4: 2010,
5: 2010,
6: 2010,
7: 2010,
8: 2010,
9: 2010,
10: 2010,
11: 2010,
12: 2011,
13: 2011,
14: 2011,
15: 2011,
16: 2011,
17: 2011,
18: 2011,
19: 2011,
20: 2011,
21: 2011,
22: 2012,
23: 2012,
24: 2012,
25: 2012,
26: 2012,
27: 2012,
28: 2012,
29: 2012,
30: 2012,
31: 2012}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.