Typically financial data is ordered by columns in reverse chronology ie columns '2020', '2019', '2018', '2017'.. But we need the pct_change function in reverse order. Looking at the Pandas reference (last example): https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.pct_change.html?highlight=pct_change#pandas.DataFrame.pct_change
df.pct_change(axis='columns')
GOOG NaN -0.151997 -0.086016
APPL NaN 0.337604 0.012002
Such a calculation makes no sense or at least is not useful. We need to look at change from today over past period, not past period over future period. Other than iterating in reverse order or transposing, can the pct_change function be augmented with a new argument to reverse the calculation to the form: (A0-A1)/A1 instead of (A1-A0)/A0 ??
Typically financial data is ordered by columns in reverse chronology ie columns '2020', '2019', '2018', '2017'.. But we need the pct_change function in reverse order. Looking at the Pandas reference (last example): https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.pct_change.html?highlight=pct_change#pandas.DataFrame.pct_change
df.pct_change(axis='columns')
GOOG NaN -0.151997 -0.086016
APPL NaN 0.337604 0.012002
Such a calculation makes no sense or at least is not useful. We need to look at change from today over past period, not past period over future period. Other than iterating in reverse order or transposing, can the pct_change function be augmented with a new argument to reverse the calculation to the form: (A0-A1)/A1 instead of (A1-A0)/A0 ??