Skip to content

Commit

Permalink
individual_search_page: Add text on multiples of inflation
Browse files Browse the repository at this point in the history
  • Loading branch information
astrochun committed Oct 19, 2021
1 parent 17d12e8 commit 2ebb885
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion salary_app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,17 @@ def individual_search_page(data_dict: dict, unique_df: pd.DataFrame):
n_years = float(in_fy_list[-1].split('-')[0].replace('FY', '')) - \
float(in_fy_list[0].split('-')[0].replace('FY', ''))
avg_y2y = 100 * (salary_arr[-1] - salary_arr[0])/salary_arr[0] / n_years
st.write(f"_Average year-to-year growth_: {avg_y2y:.2f}%")

# Get average inflation data
inflation_list = [INFLATION_DATA[key] for key in in_fy_list[1:]]
cumul_inflation = 1
for infl in inflation_list:
cumul_inflation *= 1 + infl / 100
avg_inflation = (cumul_inflation-1)/n_years * 100

st.write(f"_Average year-to-year growth_: {avg_y2y:.2f}% "
f"({avg_y2y/avg_inflation:.2f}x inflation)")

st.write(f"_Average year-to-year CPI inflation_: "
f"{avg_inflation:.2f}%")
record_df.insert(len(record_df.columns), 'CPI %',
Expand Down

0 comments on commit 2ebb885

Please sign in to comment.