Skip to content

Commit

Permalink
Merge pull request #1917 from martinholmer/add-table-row
Browse files Browse the repository at this point in the history
Add row for those with zero income to distribution and difference tables
  • Loading branch information
MattHJensen authored Mar 16, 2018
2 parents fa0d040 + 5e4d646 commit e977a0a
Show file tree
Hide file tree
Showing 21 changed files with 224 additions and 182 deletions.
64 changes: 38 additions & 26 deletions taxcalc/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,12 @@ def distribution_tables(self, calc,
result_type='weighted_sum'):
"""
Get results from self and calc, sort them based on groupby using
income_measure, manipulate grouped statistics based on result_type,
income_measure, compute grouped statistics based on result_type,
and return tables as a pair of Pandas dataframes.
This method leaves the Calculator object(s) unchanged.
Note that the returned tables have consistent income groups (based
on the self income_measure) even though the baseline income_measure
in self and the income_measure in calc are different.
Also, note that some subgroups may contain filing units with negative
or zero baseline (self) income.
Parameters
----------
Expand All @@ -414,29 +412,37 @@ def distribution_tables(self, calc,
if calc is None, the second returned table is None
groupby : String object
options for input: 'weighted_deciles', 'webapp_income_bins',
options for input: 'weighted_deciles', 'standard_income_bins',
'large_income_bins', 'small_income_bins';
determines how the columns in returned tables are sorted
NOTE: when groupby is 'weighted_deciles', the returned table has three
extra rows containing top-decile detail consisting of statistics
for the 0.90-0.95 quantile range (bottom half of top decile),
for the 0.95-0.99 quantile range, and
for the 0.99-1.00 quantile range (top one percent).
determines how the columns in resulting Pandas DataFrame are sorted
income_measure : String object
options for input: 'expanded_income' or 'c00100'(AGI)
specifies statistic used to place filing units in bins or deciles
result_type : String object
options for input: 'weighted_sum' or 'weighted_avg';
determines how whether or not table entries are averages or totals
determines how the table statistices are computed
Typical usage
-------------
Return and typical usage
------------------------
dist1, dist2 = calc1.distribution_tables(calc2)
OR
dist1, _ = calc1.distribution_tables(None)
(where calc1 is a baseline Calculator object
and calc2 is a reform Calculator object)
and calc2 is a reform Calculator object).
Each of the dist1 and optional dist2 is a distribution table as a
Pandas DataFrame with DIST_TABLE_COLUMNS and groupby rows.
NOTE: when groupby is 'weighted_deciles', the returned tables have 3
extra rows containing top-decile detail consisting of statistics
for the 0.90-0.95 quantile range (bottom half of top decile),
for the 0.95-0.99 quantile range, and
for the 0.99-1.00 quantile range (top one percent); and the
returned table splits the bottom decile into filing units with
negative (denoted by a 0-10n row label),
zero (denoted by a 0-10z row label), and
positive (denoted by a 0-10p row label) values of the
specified income_measure.
"""
# nested function used only by this method
def have_same_income_measure(calc1, calc2, income_measure):
Expand Down Expand Up @@ -495,36 +501,42 @@ def difference_table(self, calc,
in self and the income_measure in calc are different.
Note that filing units are put into groupby categories using the
specified income_measure in the baseline (self) situation.
Also, note that some subgroups may contain filing units with negative
or zero baseline (self) income.
Parameters
----------
calc : Calculator object
calc represents the reform while self represents the baseline
groupby : String object
options for input: 'weighted_deciles', 'webapp_income_bins',
options for input: 'weighted_deciles', 'standard_income_bins',
'large_income_bins', 'small_income_bins';
determines how the columns in returned tables are sorted
NOTE: when groupby is 'weighted_deciles', the returned table has three
extra rows containing top-decile detail consisting of statistics
for the 0.90-0.95 quantile range (bottom half of top decile),
for the 0.95-0.99 quantile range, and
for the 0.99-1.00 quantile range (top one percent).
determines how the columns in resulting Pandas DataFrame are sorted
income_measure : String object
options for input: 'expanded_income' or 'c00100'(AGI)
specifies statistic used to place filing units in bins or deciles
tax_to_diff : String object
options for input: 'iitax', 'payrolltax', 'combined'
specifies which tax to difference
Typical usage
-------------
Returns and typical usage
-------------------------
diff = calc1.difference_table(calc2)
(where calc1 is a baseline Calculator object
and calc2 is a reform Calculator object)
and calc2 is a reform Calculator object).
The returned diff is a difference table as a Pandas DataFrame
with DIST_TABLE_COLUMNS and groupby rows.
NOTE: when groupby is 'weighted_deciles', the returned table has three
extra rows containing top-decile detail consisting of statistics
for the 0.90-0.95 quantile range (bottom half of top decile),
for the 0.95-0.99 quantile range, and
for the 0.99-1.00 quantile range (top one percent); and the
returned table splits the bottom decile into filing units with
negative (denoted by a 0-10n row label),
zero (denoted by a 0-10z row label), and
positive (denoted by a 0-10p row label) values of the
specified income_measure.
"""
assert isinstance(calc, Calculator)
assert calc.current_year == self.current_year
Expand Down
13 changes: 7 additions & 6 deletions taxcalc/reforms/2017_law.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 60000 12995 16792 30213 3466 489 9180 54921
5 0 0 0 0 0 0 0 0
6 180000 30322 30375 119303 16514 13514 27540 152716
7 0 0 0 0 0 0 0 0
8 240000 25990 23584 190426 32344 30844 36720 190796
9 600000 18875 20375 560750 142810 142810 66067 423437
4 0 0 0 0 0 0 0 0
5 60000 12995 16792 30213 3466 489 9180 54921
6 0 0 0 0 0 0 0 0
7 180000 30322 30375 119303 16514 13514 27540 152716
8 0 0 0 0 0 0 0 0
9 240000 25990 23584 190426 32344 30844 36720 190796
10 600000 18875 20375 560750 142810 142810 66067 423437
sums 1080000 88182 91126 900692 195134 187657 139507 821869
13 changes: 7 additions & 6 deletions taxcalc/reforms/BrownKhanna.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 60000 12995 16792 30213 3466 -4405 9180 59815
5 0 0 0 0 0 0 0 0
6 180000 30322 30375 119303 16514 8698 27540 157532
7 0 0 0 0 0 0 0 0
8 240000 25990 23584 190426 32344 30844 36720 190796
9 600000 18875 20375 560750 142810 142810 66067 423437
4 0 0 0 0 0 0 0 0
5 60000 12995 16792 30213 3466 -4405 9180 59815
6 0 0 0 0 0 0 0 0
7 180000 30322 30375 119303 16514 8698 27540 157532
8 0 0 0 0 0 0 0 0
9 240000 25990 23584 190426 32344 30844 36720 190796
10 600000 18875 20375 560750 142810 142810 66067 423437
sums 1080000 88182 91126 900692 195134 177947 139507 831580
13 changes: 7 additions & 6 deletions taxcalc/reforms/Clinton2016.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 60000 12995 16792 30213 3466 -511 9180 55921
5 0 0 0 0 0 0 0 0
6 180000 30322 30375 119303 16514 11514 27540 154716
7 0 0 0 0 0 0 0 0
8 240000 25990 23584 190426 32344 29844 36720 191796
9 600000 18875 20375 560750 142810 142810 66067 423437
4 0 0 0 0 0 0 0 0
5 60000 12995 16792 30213 3466 -511 9180 55921
6 0 0 0 0 0 0 0 0
7 180000 30322 30375 119303 16514 11514 27540 154716
8 0 0 0 0 0 0 0 0
9 240000 25990 23584 190426 32344 29844 36720 191796
10 600000 18875 20375 560750 142810 142810 66067 423437
sums 1080000 88182 91126 900692 195134 183657 139507 825869
13 changes: 7 additions & 6 deletions taxcalc/reforms/Renacci.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 60000 16043 32087 11870 1187 -3245 9180 58655
5 0 0 0 0 0 0 0 0
6 180000 37434 64173 78393 7839 3676 27540 162554
7 0 0 0 0 0 0 0 0
8 240000 32087 48130 159784 21946 20446 36720 201194
9 600000 23303 48130 528567 108077 108077 66067 458170
4 0 0 0 0 0 0 0 0
5 60000 16043 32087 11870 1187 -3245 9180 58655
6 0 0 0 0 0 0 0 0
7 180000 37434 64173 78393 7839 3676 27540 162554
8 0 0 0 0 0 0 0 0
9 240000 32087 48130 159784 21946 20446 36720 201194
10 600000 23303 48130 528567 108077 108077 66067 458170
sums 1080000 108867 192519 778613 139049 128954 139507 880572
13 changes: 7 additions & 6 deletions taxcalc/reforms/RyanBrady.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 60000 0 32087 27913 3350 83 9180 55327
5 0 0 0 0 0 0 0 0
6 180000 0 57756 122244 15524 11024 27540 155206
7 0 0 0 0 0 0 0 0
8 240000 0 44921 195079 31153 28153 36720 193487
9 600000 0 38504 561496 135919 135919 66067 430328
4 0 0 0 0 0 0 0 0
5 60000 0 32087 27913 3350 83 9180 55327
6 0 0 0 0 0 0 0 0
7 180000 0 57756 122244 15524 11024 27540 155206
8 0 0 0 0 0 0 0 0
9 240000 0 44921 195079 31153 28153 36720 193487
10 600000 0 38504 561496 135919 135919 66067 430328
sums 1080000 0 173268 906732 185946 175179 139507 834347
13 changes: 7 additions & 6 deletions taxcalc/reforms/TCJA_House.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 60000 0 31227 28773 3453 -675 9180 56085
5 0 0 0 0 0 0 0 0
6 180000 0 56209 123791 14942 8942 27540 157288
7 0 0 0 0 0 0 0 0
8 240000 0 43718 196282 27758 23008 36720 198632
9 600000 0 37473 562527 136297 134397 66067 431850
4 0 0 0 0 0 0 0 0
5 60000 0 31227 28773 3453 -675 9180 56085
6 0 0 0 0 0 0 0 0
7 180000 0 56209 123791 14942 8942 27540 157288
8 0 0 0 0 0 0 0 0
9 240000 0 43718 196282 27758 23008 36720 198632
10 600000 0 37473 562527 136297 134397 66067 431850
sums 1080000 0 168627 911373 182449 165671 139507 843855
13 changes: 7 additions & 6 deletions taxcalc/reforms/TCJA_House_Amended.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 60000 0 31227 28773 3453 -675 9180 56085
5 0 0 0 0 0 0 0 0
6 180000 0 56209 123791 14942 8942 27540 157288
7 0 0 0 0 0 0 0 0
8 240000 0 43718 196282 27758 23008 36720 198632
9 600000 0 37473 562527 136297 134397 66067 431850
4 0 0 0 0 0 0 0 0
5 60000 0 31227 28773 3453 -675 9180 56085
6 0 0 0 0 0 0 0 0
7 180000 0 56209 123791 14942 8942 27540 157288
8 0 0 0 0 0 0 0 0
9 240000 0 43718 196282 27758 23008 36720 198632
10 600000 0 37473 562527 136297 134397 66067 431850
sums 1080000 0 168627 911373 182449 165671 139507 843855
13 changes: 7 additions & 6 deletions taxcalc/reforms/TCJA_Reconciliation.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 60000 0 31227 28773 3029 -898 9180 56308
5 0 0 0 0 0 0 0 0
6 180000 0 56209 123791 14699 8699 27540 157531
7 0 0 0 0 0 0 0 0
8 240000 0 43718 196282 29361 23361 36720 198279
9 600000 0 37473 562527 136039 132039 66067 434207
4 0 0 0 0 0 0 0 0
5 60000 0 31227 28773 3029 -898 9180 56308
6 0 0 0 0 0 0 0 0
7 180000 0 56209 123791 14699 8699 27540 157531
8 0 0 0 0 0 0 0 0
9 240000 0 43718 196282 29361 23361 36720 198279
10 600000 0 37473 562527 136039 132039 66067 434207
sums 1080000 0 168627 911373 183129 163202 139507 846325
13 changes: 7 additions & 6 deletions taxcalc/reforms/TCJA_Senate.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 60000 0 31227 28773 3029 -548 9180 55958
5 0 0 0 0 0 0 0 0
6 180000 0 56209 123791 14736 9786 27540 156444
7 0 0 0 0 0 0 0 0
8 240000 0 43718 196282 30333 25383 36720 196257
9 600000 0 37473 562527 138938 135638 66067 430608
4 0 0 0 0 0 0 0 0
5 60000 0 31227 28773 3029 -548 9180 55958
6 0 0 0 0 0 0 0 0
7 180000 0 56209 123791 14736 9786 27540 156444
8 0 0 0 0 0 0 0 0
9 240000 0 43718 196282 30333 25383 36720 196257
10 600000 0 37473 562527 138938 135638 66067 430608
sums 1080000 0 168627 911373 187036 170259 139507 839268
13 changes: 7 additions & 6 deletions taxcalc/reforms/TCJA_Senate_111417.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 60000 0 31227 28773 3029 -898 9180 56308
5 0 0 0 0 0 0 0 0
6 180000 0 56209 123791 14699 8699 27540 157531
7 0 0 0 0 0 0 0 0
8 240000 0 43718 196282 29622 23622 36720 198018
9 600000 0 37473 562527 136612 132612 66067 433635
4 0 0 0 0 0 0 0 0
5 60000 0 31227 28773 3029 -898 9180 56308
6 0 0 0 0 0 0 0 0
7 180000 0 56209 123791 14699 8699 27540 157531
8 0 0 0 0 0 0 0 0
9 240000 0 43718 196282 29622 23622 36720 198018
10 600000 0 37473 562527 136612 132612 66067 433635
sums 1080000 0 168627 911373 183962 164035 139507 845492
Loading

0 comments on commit e977a0a

Please sign in to comment.