Skip to content

Instantly share code, notes, and snippets.

@AntoniosHadji
Created May 1, 2024 21:26
Show Gist options
  • Save AntoniosHadji/a56457aaba366246e3da6dc5842984b3 to your computer and use it in GitHub Desktop.
Save AntoniosHadji/a56457aaba366246e3da6dc5842984b3 to your computer and use it in GitHub Desktop.
Calculate income tax on taxable income
# tiers are for married filing jointly 2024
over = [
0,
23200,
94300,
201050,
383900,
487450,
731200
]
rates = [
0.10,
0.12,
0.22,
0.24,
0.32,
0.35,
0.37
]
data = { "over": pd.Series(over), "notover": pd.Series(over).shift(-1), "rate": pd.Series(rates)}
tt = pd.DataFrame(data)
def calc_tax(n):
lower = tt[tt.over < n].head(-1)
final = tt[tt.over < n].tail(1)
return np.sum((lower.notover-lower.over)*lower.rate) + ((n - final.over)*final.rate).item()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment