Created
November 10, 2017 17:33
-
-
Save justbuchanan/af7bbfb1d9ba97f32ef54f608417c59c to your computer and use it in GitHub Desktop.
How does your income tax compare now vs with the new GOP/Trump tax brackets?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# data from: https://smartasset.com/taxes/heres-how-the-trump-tax-plan-could-affect-you | |
# note: this applies to single filers only | |
import matplotlib.pyplot as plt | |
import numpy as np | |
brackets_old = [ | |
(9325.0, .1), | |
(37950.0, .15), | |
(91900.0, .25), | |
(191650.0, .28), | |
(416700.0, .33), | |
(418400.0, .35), | |
(float("inf"), .396), | |
] | |
brackets_new = [ | |
(45000.0, .12), | |
(200000.0, .25), | |
(500000.0, .35), | |
(float("inf"), .396), | |
] | |
def calculate_tax(income, brackets): | |
tax = 0 | |
bracket = 0 | |
while income > 0: | |
brkt_max, rate = brackets[bracket] | |
brkt_min = 0 if bracket == 0 else brackets[bracket-1][0] | |
brkt_width = brkt_max - brkt_min | |
amt_at_this_rate = min(brkt_width, income) | |
income -= amt_at_this_rate | |
tax += rate * amt_at_this_rate | |
# print(" bracket %d, %0.f-%0.f" % (bracket, brkt_min, brkt_max)) | |
# print(" amt: %0.f" % amt_at_this_rate) | |
bracket += 1 | |
return tax | |
def tax_diff_summary(income): | |
tax_before = calculate_tax(income, brackets_old) | |
tax_after = calculate_tax(income, brackets_new) | |
dt = tax_before - tax_after # positive means you're saving money | |
print("Income: $%0.f" % income) | |
print("Tax Before:") | |
print(" $%0.f = %0.2f%%" % (tax_before, (tax_before / income)*100)) | |
print("Tax After:") | |
print(" $%0.f = %0.2f%%" % (tax_after, (tax_after / income)*100)) | |
print("Difference:") | |
print(" $%0.f = %0.2f%%" % (tax_after, (tax_after / income)*100)) | |
print(" $%0.f" % dt) | |
print(" %0.2f%%" % (dt / income)) | |
def graph_income_vs_savings(): | |
incomes = np.arange(1, 1500, 1) | |
diff = [calculate_tax(i*1000, brackets_old) - calculate_tax(i*1000, brackets_new) for i in incomes] | |
plt.plot(incomes, diff) | |
plt.title("Income vs tax savings") | |
plt.xlabel("Annual income (thousands)") | |
plt.ylabel("Tax savings (dollars)") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment