Simplified key to access dataframe.

This commit is contained in:
likho 2025-09-28 09:59:09 -07:00
parent 8763f28547
commit c646b1d80b

View File

@ -43,7 +43,7 @@ def get_balances_over_time(names, balances, func, terms=4):
} }
df = pd.DataFrame(data) df = pd.DataFrame(data)
for t in range(1,terms): for t in range(1,terms):
key = "term%i" % t key = str(t)
frame = func(balances, terms=t) frame = func(balances, terms=t)
if frame is not None: if frame is not None:
df[key] = frame df[key] = frame
@ -66,6 +66,8 @@ def illustrate_share_of_wealth():
df = get_balances_over_time ( df = get_balances_over_time (
participants, balances, compounding_interest participants, balances, compounding_interest
) )
df["share"] = [val * 100 for val in calc_share_of_wealth(df["3"]) ]
print(df.to_html()) print(df.to_html())
terms = 222 terms = 222
@ -87,7 +89,7 @@ def illustrate_share_of_wealth():
print("What is the share of wealth in a UBI economy?") print("What is the share of wealth in a UBI economy?")
print(calc_share_of_wealth(u)) print(calc_share_of_wealth(u))
# illustrate_share_of_wealth() illustrate_share_of_wealth()
def visualize_ubi(terms=25): def visualize_ubi(terms=25):
@ -122,7 +124,7 @@ def visualize_ubi(terms=25):
x, sow[2], color="cyan", label=participants[2] x, sow[2], color="cyan", label=participants[2]
) )
plt.axhline( 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") 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)" x, total_supply_ubi, color="cyan", label="UBI (n=3, du=10)"
) )
plt.plot( 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.title("Money Supply over Time: UBI vs Compounding Interest")
plt.legend() plt.legend()