Skip to content

Instantly share code, notes, and snippets.

@rbtcollins
Created March 23, 2016 01:08
Show Gist options
  • Save rbtcollins/babb983b8939b051fe5d to your computer and use it in GitHub Desktop.
Save rbtcollins/babb983b8939b051fe5d to your computer and use it in GitHub Desktop.
import csv
f = open('income-distribution.csv', 'rt')
l = list(csv.reader(f))
pre = l[5:157]
# top edge, lower edge, %
brackets = [(14000, 0, 0.105), (48000, 14001, 0.175), (70000, 48001, 0.30), (200000, 70001, 0.33)]
total = 0
for (_, people, total_income, _) in pre:
people = float(people)
total_income = float(total_income) * 1000000
avg = total_income/people
newincome = avg + 11000
for idx, (threshold, lower, pct) in enumerate(brackets):
if threshold > newincome:
break
# tax from the new bracket
base = max(lower, avg)
newtax = (newincome-base) * people * pct
# 10K, 48 > 21.
if lower > avg:
# crosses a bracket
newtax += (lower-avg) * people * brackets[idx-1][2]
print("avg: %s, newtax: %s" % (avg, newtax/1000000))
total += newtax
print("Total: %s" % (total/1000000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment