I have a daily timeseries of indexdata and want to take yearly pct changes of it. If I use DataFrame.pct_change(periods=...) I will have to define the exact number of days till the same day last year which is not correct as the number of working days differs from year to year. Do anyone have any idea how to get the changes from the same day a year back ?
The code may look like:
import pandas as pd
list=[]
list=[[7.71],[7.79],[6.80],[6.44],[6.46],[6.80]]
df = pd.DataFrame(list, columns=['index'], index=['2016-01-04','2016-01-05','2016-01-06','2017-01-04','2017-01-05','2017-01-06'])
and I want the output as follows:
2017-01-04 -16.45%
2017-01-05 -17.10%
2017-01-05 0.00%