Skip to content

Instantly share code, notes, and snippets.

@antonioshadji
Last active January 16, 2026 15:12
Show Gist options
  • Select an option

  • Save antonioshadji/a56457aaba366246e3da6dc5842984b3 to your computer and use it in GitHub Desktop.

Select an option

Save antonioshadji/a56457aaba366246e3da6dc5842984b3 to your computer and use it in GitHub Desktop.
Calculate income tax on taxable income
import pandas as pd
import numpy as np
# tax tables for 2026 from page 10 of https://www.irs.gov/pub/irs-drop/rp-25-32.pdf
# married filing jointly
over = [
0,
24800,
100800,
211400,
403550,
512450,
768700
]
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()
if __name__ == '__main__':
# replace 0 with your expected annual income calculation
annual_income = 0
print(annual_income, calc_tax(annual_income))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment