From c646b1d80b5439d34002837ddeae9b12725633c5 Mon Sep 17 00:00:00 2001 From: likho Date: Sun, 28 Sep 2025 09:59:09 -0700 Subject: [PATCH] Simplified key to access dataframe. --- econ-demo.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/econ-demo.py b/econ-demo.py index cfcca1a..683ef8f 100644 --- a/econ-demo.py +++ b/econ-demo.py @@ -43,7 +43,7 @@ def get_balances_over_time(names, balances, func, terms=4): } df = pd.DataFrame(data) for t in range(1,terms): - key = "term%i" % t + key = str(t) frame = func(balances, terms=t) if frame is not None: df[key] = frame @@ -66,6 +66,8 @@ def illustrate_share_of_wealth(): df = get_balances_over_time ( participants, balances, compounding_interest ) + df["share"] = [val * 100 for val in calc_share_of_wealth(df["3"]) ] + print(df.to_html()) terms = 222 @@ -87,7 +89,7 @@ def illustrate_share_of_wealth(): print("What is the share of wealth in a UBI economy?") print(calc_share_of_wealth(u)) -# illustrate_share_of_wealth() +illustrate_share_of_wealth() def visualize_ubi(terms=25): @@ -122,7 +124,7 @@ def visualize_ubi(terms=25): x, sow[2], color="cyan", label=participants[2] ) plt.axhline( - y=0.33, color='violet', linestyle='--' + y=0.33, color='violet', linestyle='--', label="0.33" ) plt.title("Change in Wealth Distribution Under UBI") @@ -168,7 +170,7 @@ def visualize_inflation(terms=50): x, total_supply_ubi, color="cyan", label="UBI (n=3, du=10)" ) plt.plot( - x, total_supply_si, color="red", label="Debt (n=3, APY=5%)" + x, total_supply_si, color="red", label="Debt (APY=5%)" ) plt.title("Money Supply over Time: UBI vs Compounding Interest") plt.legend()