A tricky situation involving compound growth rate between two different data frames

Viewed 151

I am looking to calculate compound annual growth rate between census years (2011, 2016) and use that growth rate to extrapolate numbers for the in-between years.

For example

df_2011.head()
Age      Census_Tract_001   Census_Tract_002
0        100                600    



df_2016.head()
Age      Census_Tract_001   Census_Tract_002
0        400                360    

Then calculate CAGR between 2011 and 2016

Age      Census_Tract_001   Census_Tract_002
0        .3195              -.0971 

Apply CAGR to each of the inbetween years

create df_2012

 Age      Census_Tract_001   Census_Tract_002
 0        131.95             541.74

create df_2013

 Age      Census_Tract_001   Census_Tract_002
 0        174.108             489.137

create df_2014

 Age      Census_Tract_001   Census_Tract_002
 0        229.7355           441.6418

create df_2015

 Age      Census_Tract_001   Census_Tract_002
 0        303.136           398.7584

My attempt

I tired doing the following Number of years ny = 5

Present Turnover pt = ?

Past turnover value ppt = ?

m =(pt/ppt)

AGR = Annual Growth rate agr = float((m**1/ny)-1)*100

I tired to do this for hours but if I can't I will just ref cells in excel to calculate, sadly...

1 Answers

You can find the CAGR directly by applying formula

cagr = (df2/df)**(1/5) - 1

    Age     Census_Tract_001    Census_Tract_002
0   NaN     0.319508            -0.09712

To find the in between dfs, define a function

f = lambda c: c + c*cagr

And compound it by call it using function composition

>>> f(df)
        Age     Census_Tract_001    Census_Tract_002
0       NaN     131.950791          541.728271

>>> f(f(df))
        Age     Census_Tract_001    Census_Tract_002
0       NaN     174.110113          489.115866
Related