A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://stackoverflow.com/questions/30379789/plot-pandas-data-frame-with-year-over-year-data below:

python - Plot pandas data frame with year over year data

Is this what you want? You can add means after transformation.

df = pd.DataFrame({'value': [1, 2, 15, 3, 7, 1, 3, 8, 5, 3, 1, 1, 8, 5, 19]},
              index=pd.DatetimeIndex(['2000-01-01', '2000-03-01', '2000-06-01', '2000-09-01',
                                      '2000-12-01', '2001-01-01', '2001-03-01', '2001-06-01',
                                      '2001-09-01', '2001-12-01', '2002-01-01', '2002-03-01',
                                      '2002-06-01', '2002-09-01', '2002-12-01']))


pv = pd.pivot_table(df, index=df.index.month, columns=df.index.year,
                    values='value', aggfunc='sum')
pv
#     2000  2001  2002
# 1      1     1     1
# 3      2     3     1
# 6     15     8     8
# 9      3     5     5
# 12     7     3    19

pv.plot()


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4