I think this might help you:
In [79]: df.groupby([(df.Date.dt.year // 10 * 10), 'EPS']).mean()
Out[79]:
Price CPI
Date EPS
1970 0 0 53.0
1980 0 0 53.0
1990 0 0 53.0
2000 0 0 53.0
2010 0 0 53.0
I modified the data little bit so the years would group differently.
The data you provided wasn't really sufficient to test it, so I made some additional data that looks like this:
Date,Company,Price,EPS,CPI
1985-01-30,3M Co,0,2,56.0
1986-04-30,3M Co,0,3,93.0
1983-06-30,3M Co,0,4,18.0
1979-04-30,Abbott Laboratories,0,5,52.0
1972-03-30,Abbott Laboratories,0,6,73.0
1971-09-30,Abbott Laboratories,0,7,58.0
1995-04-30,AbbVie Inc,0,8,53.0
2015-04-30,Accenture PLC,0,9,53.0
2005-04-30,Activision Blizzard Inc,0,0,53.0
And performed the following actions:
In [83]: df=pd.DataFrame.from_csv('t.csv', index_col=None)
In [84]: df.Date = df.Date.apply(lambda x: pd.to_datetime(x))
In [85]: df.groupby([(df.Date.dt.year // 10 * 10), 'EPS']).mean()
Out[85]:
Price CPI
Date EPS
1970 5 0 52.0
6 0 73.0
7 0 58.0
1980 2 0 56.0
3 0 93.0
4 0 18.0
1990 8 0 53.0
2000 0 0 53.0
2010 9 0 53.0
Ok, assuming the same dataframe, we can set the index to Date
and perform a rolling mean grouped by decade, I believe. Here's the code:
In [52]: df = df.set_index('Date')
In [53]: df.groupby(df.index.year // 10 * 10).rolling('3650d').mean()
Out[53]:
Company Price EPS CPI
Date Date
1970 1979-04-30 Abbott Laboratories 0.0 5.0 52.000000
1972-03-30 Abbott Laboratories 0.0 5.5 62.500000
1971-09-30 Abbott Laboratories 0.0 6.0 61.000000
1980 1985-01-30 3M Co 0.0 2.0 56.000000
1986-04-30 3M Co 0.0 2.5 74.500000
1983-06-30 3M Co 0.0 3.0 55.666667
1990 1995-04-30 AbbVie Inc 0.0 8.0 53.000000
2000 2005-04-30 Activision Blizzard Inc 0.0 0.0 53.000000
2010 2015-04-30 Accenture PLC 0.0 9.0 53.000000
Grouped by decade and company:
In [67]: df.groupby([df.index.year // 10 * 10, df.Company]).rolling('3650d').mean()
...:
Out[67]:
Company Price EPS \
Date Company Date
1970 Abbott Laboratories 1979-04-30 Abbott Laboratories 0.0 5.0
1972-03-30 Abbott Laboratories 0.0 5.5
1971-09-30 Abbott Laboratories 0.0 6.0
1980 3M Co 1985-01-30 3M Co 0.0 2.0
1986-04-30 3M Co 0.0 2.5
1983-06-30 3M Co 0.0 3.0
1990 AbbVie Inc 1995-04-30 AbbVie Inc 0.0 8.0
2000 Activision Blizzard Inc 2005-04-30 Activision Blizzard Inc 0.0 0.0
2010 Accenture PLC 2015-04-30 Accenture PLC 0.0 9.0
CPI
Date Company Date
1970 Abbott Laboratories 1979-04-30 52.000000
1972-03-30 62.500000
1971-09-30 61.000000
1980 3M Co 1985-01-30 56.000000
1986-04-30 74.500000
1983-06-30 55.666667
1990 AbbVie Inc 1995-04-30 53.000000
2000 Activision Blizzard Inc 2005-04-30 53.000000
2010 Accenture PLC 2015-04-30 53.000000