From 6188f0c75e27cc04db5b237bc33b057a240e9d08 Mon Sep 17 00:00:00 2001 From: PavelMakarchuk Date: Tue, 3 Dec 2024 16:05:50 -0500 Subject: [PATCH 1/3] Add children numbers to the dependent exemptions notebook --- test.ipynb | 0 .../repeal_state_dependent_exemptions.ipynb | 261 ++++++++++++++++++ .../state_impacts_detailed.csv | 29 +- 3 files changed, 289 insertions(+), 1 deletion(-) create mode 100644 test.ipynb diff --git a/test.ipynb b/test.ipynb new file mode 100644 index 0000000..e69de29 diff --git a/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb b/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb index 86c5a09..12ebd2f 100644 --- a/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb +++ b/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb @@ -210,6 +210,267 @@ "final_results.to_csv('state_impacts_detailed.csv', index=False)" ] }, + { + "cell_type": "code", + "execution_count": 43, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "State-by-State Analysis of Children in Households with Zero State Exemptions:\n", + " state_code children_in_zero_exemption percent_children_in_zero_exemption\n", + "0 AK 183148.0 100.00\n", + "1 AL 0.0 0.00\n", + "2 AR 674473.0 100.00\n", + "3 AZ 1462527.0 100.00\n", + "4 CA 142232.0 1.85\n", + "5 CO 1192968.0 100.00\n", + "6 CT 688379.0 100.00\n", + "7 DC 96332.0 100.00\n", + "8 DE 218417.0 100.00\n", + "9 FL 4147576.0 100.00\n", + "10 GA 0.0 0.00\n", + "11 HI 0.0 0.00\n", + "12 IA 807211.0 100.00\n", + "13 ID 503665.0 100.00\n", + "14 IL 0.0 0.00\n", + "15 IN 0.0 0.00\n", + "16 KS 0.0 0.00\n", + "17 KY 1014111.0 100.00\n", + "18 LA 0.0 0.00\n", + "19 MA 1358035.0 100.00\n", + "20 MD 266472.0 20.70\n", + "21 ME 233492.0 100.00\n", + "22 MI 0.0 0.00\n", + "23 MN 39231.0 3.05\n", + "24 MO 1491649.0 100.00\n", + "25 MS 0.0 0.00\n", + "26 MT 244193.0 100.00\n", + "27 NC 2249389.0 100.00\n", + "28 ND 193633.0 100.00\n", + "29 NE 0.0 0.00\n", + "30 NH 268315.0 100.00\n", + "31 NJ 0.0 0.00\n", + "32 NM 460692.0 100.00\n", + "33 NV 673834.0 100.00\n", + "34 NY 0.0 0.00\n", + "35 OH 204579.0 8.06\n", + "36 OK 0.0 0.00\n", + "37 OR 857949.0 100.00\n", + "38 PA 2522785.0 100.00\n", + "39 RI 17859.0 8.52\n", + "40 SC 0.0 0.00\n", + "41 SD 211732.0 100.00\n", + "42 TN 1510758.0 100.00\n", + "43 TX 7005304.0 100.00\n", + "44 UT 943211.0 100.00\n", + "45 VA 0.0 0.00\n", + "46 VT 0.0 0.00\n", + "47 WA 1706458.0 100.00\n", + "48 WI 1360253.0 100.00\n", + "49 WV 0.0 0.00\n", + "50 WY 138867.0 100.00\n" + ] + } + ], + "source": [ + "# Calculate household income and number of children\n", + "household_income = baseline.calculate(\"household_net_income\", period=2024)\n", + "num_children = baseline.calculate(\"tax_unit_children\", map_to='household', period=2024)\n", + "# Create a mapping of state codes to their exemption variables\n", + "state_to_exemption = {\n", + " 'AL': ['al_personal_exemption'],\n", + " 'CA': ['ca_exemptions'],\n", + " 'GA': ['ga_exemptions'],\n", + " 'HI': ['hi_exemptions'],\n", + " 'IN': ['in_base_exemptions'],\n", + " 'IL': ['il_dependent_exemption'],\n", + " 'KS': ['ks_exemptions'],\n", + " 'LA': ['la_dependents_exemption'],\n", + " 'MD': ['md_total_personal_exemptions'],\n", + " 'MI': ['mi_exemptions'],\n", + " 'MN': ['mn_exemptions'],\n", + " 'MS': ['ms_dependents_exemption'],\n", + " 'NE': ['ne_exemptions'],\n", + " 'NJ': ['nj_dependents_exemption'],\n", + " 'NY': ['ny_exemptions'],\n", + " 'OH': ['oh_personal_exemptions'],\n", + " 'OK': ['ok_exemptions'],\n", + " 'RI': ['ri_exemptions'],\n", + " 'SC': ['sc_dependent_exemption'],\n", + " 'VA': ['va_personal_exemption'],\n", + " 'VT': ['vt_personal_exemptions'],\n", + " 'WV': ['wv_personal_exemption']\n", + "}\n", + "\n", + "# Calculate exemptions state by state\n", + "total_exemptions = np.zeros_like(household_income)\n", + "state_codes = baseline.calculate(\"state_code\", period=2024)\n", + "\n", + "# Add debug prints\n", + "for state, exemption_list in state_to_exemption.items():\n", + " state_mask = (state_codes == state)\n", + " state_exemptions = np.zeros_like(household_income)\n", + " \n", + " for var in exemption_list:\n", + " try:\n", + " # Map tax unit variables to household level\n", + " exemption_value = baseline.calculate(var, map_to=\"household\", period=2024)\n", + " state_exemptions += exemption_value\n", + " except Exception as e:\n", + " continue\n", + " \n", + " total_exemptions[state_mask] = state_exemptions[state_mask]\n", + "\n", + "\n", + "\n", + "\n", + "results_df['total_children'] = num_children\n", + "\n", + "\n", + "# Identify children in households with zero exemptions\n", + "children_in_zero_exemption = (total_exemptions == 0).astype(int) * num_children\n", + "# Add to results DataFrame\n", + "results_df['children_in_zero_exemption'] = children_in_zero_exemption\n", + "\n", + "# Get household weights for accurate aggregation\n", + "weights = baseline.calculate(\"household_weight\", period=2024)\n", + "results_df['weight'] = weights\n", + "\n", + "# Calculate state-level statistics with weights\n", + "state_children_impact = (\n", + " results_df\n", + " .groupby('state_code')\n", + " .agg({\n", + " 'children_in_zero_exemption': lambda x: np.sum(x * results_df.loc[x.index, 'weight']),\n", + " 'total_children': lambda x: np.sum(x * results_df.loc[x.index, 'weight'])\n", + " })\n", + " .reset_index()\n", + ")\n", + "\n", + "# Calculate percentage using total children as denominator\n", + "state_children_impact['percent_children_in_zero_exemption'] = (\n", + " state_children_impact['children_in_zero_exemption'] / state_children_impact['total_children'] * 100\n", + ")\n", + "\n", + "# Format and display results\n", + "state_children_impact['children_in_zero_exemption'] = state_children_impact['children_in_zero_exemption'].round(0)\n", + "state_children_impact['percent_children_in_zero_exemption'] = state_children_impact['percent_children_in_zero_exemption'].round(2)\n", + "\n", + "print(\"\\nState-by-State Analysis of Children in Households with Zero State Exemptions:\")\n", + "print(state_children_impact[[\n", + " 'state_code',\n", + " 'children_in_zero_exemption',\n", + " 'percent_children_in_zero_exemption'\n", + "]].to_string())" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "Children in households with zero tax in both scenarios (unweighted):\n", + " state_code total_children children_zero_tax percent_zero_tax\n", + "16 OK 1,849.0 1,090.0 59.0\n", + "21 VT 1,154.0 676.0 58.6\n", + "14 NY 3,629.0 2,029.0 55.9\n", + "13 NJ 2,013.0 1,100.0 54.6\n", + "19 TX 7,333.0 3,984.0 54.3\n", + "17 RI 823.0 408.0 49.6\n", + "22 WV 1,968.0 938.0 47.7\n", + "3 HI 1,649.0 783.0 47.5\n", + "8 MD 1,272.0 581.0 45.7\n", + "10 MN 1,574.0 716.0 45.5\n", + "2 GA 2,386.0 1,063.0 44.6\n", + "20 VA 2,098.0 932.0 44.4\n", + "1 CA 9,521.0 4,179.0 43.9\n", + "7 LA 2,549.0 1,108.0 43.5\n", + "9 MI 2,457.0 984.0 40.0\n", + "12 NE 1,546.0 615.0 39.8\n", + "11 MS 1,819.0 656.0 36.1\n", + "18 SC 1,913.0 672.0 35.1\n", + "4 IL 3,003.0 1,054.0 35.1\n", + "0 AL 2,136.0 723.0 33.8\n", + "15 OH 2,476.0 801.0 32.4\n", + "6 KS 1,543.0 444.0 28.8\n", + "5 IN 1,946.0 500.0 25.7\n" + ] + } + ], + "source": [ + "# Define states with exemptions\n", + "state_to_exemption = {\n", + " 'AL': ['al_personal_exemption'], 'CA': ['ca_exemptions'],\n", + " 'GA': ['ga_exemptions'], 'HI': ['hi_exemptions'],\n", + " 'IN': ['in_base_exemptions'], 'IL': ['il_dependent_exemption'],\n", + " 'KS': ['ks_exemptions'], 'LA': ['la_dependents_exemption'],\n", + " 'MD': ['md_total_personal_exemptions'], 'MI': ['mi_exemptions'],\n", + " 'MN': ['mn_exemptions'], 'MS': ['ms_dependents_exemption'],\n", + " 'NE': ['ne_exemptions'], 'NJ': ['nj_dependents_exemption'],\n", + " 'NY': ['ny_exemptions'], 'OH': ['oh_personal_exemptions'],\n", + " 'OK': ['ok_exemptions'], 'RI': ['ri_exemptions'],\n", + " 'SC': ['sc_dependent_exemption'], 'VA': ['va_personal_exemption'],\n", + " 'VT': ['vt_personal_exemptions'], 'WV': ['wv_personal_exemption']\n", + "}\n", + "\n", + "# Get required variables\n", + "state_codes = baseline.calculate(\"state_code\", period=2024)\n", + "num_children = baseline.calculate(\"tax_unit_children\", map_to='household', period=2024)\n", + "baseline_tax = baseline.calculate(\"state_income_tax_before_refundable_credits\", period=2024)\n", + "reformed_tax = reformed.calculate(\"state_income_tax_before_refundable_credits\", period=2024)\n", + "\n", + "# Create results DataFrame\n", + "results = pd.DataFrame({\n", + " 'state_code': state_codes,\n", + " 'num_children': num_children,\n", + " 'zero_tax_both': (np.abs(baseline_tax) < 0.01) & (np.abs(reformed_tax) < 0.01)\n", + "})\n", + "\n", + "# Filter for states we want to analyze (exemption states + TX for verification)\n", + "states_to_show = list(state_to_exemption.keys()) + ['TX']\n", + "results = results[results['state_code'].isin(states_to_show)]\n", + "\n", + "# Calculate total children by state (unweighted)\n", + "total_children = (\n", + " results\n", + " .groupby('state_code')\n", + " ['num_children']\n", + " .sum()\n", + " .reset_index(name='total_children')\n", + ")\n", + "\n", + "# Calculate children with zero tax in both scenarios (unweighted)\n", + "zero_tax_children = (\n", + " results[results['zero_tax_both']]\n", + " .groupby('state_code')\n", + " ['num_children']\n", + " .sum()\n", + " .reset_index(name='children_zero_tax')\n", + ")\n", + "\n", + "# Merge results\n", + "state_results = total_children.merge(zero_tax_children, on='state_code', how='left').fillna(0)\n", + "\n", + "# Calculate percentage\n", + "state_results['percent_zero_tax'] = (\n", + " state_results['children_zero_tax'] / state_results['total_children'] * 100\n", + ").round(1)\n", + "\n", + "# Sort and display results\n", + "state_results = state_results.sort_values('percent_zero_tax', ascending=False)\n", + "print(\"\\nChildren in households with zero tax in both scenarios (unweighted):\")\n", + "print(state_results.to_string(float_format=lambda x: f\"{x:,.1f}\"))" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/us/state_dependent_exemptions/state_impacts_detailed.csv b/us/state_dependent_exemptions/state_impacts_detailed.csv index d25815e..91c13fc 100644 --- a/us/state_dependent_exemptions/state_impacts_detailed.csv +++ b/us/state_dependent_exemptions/state_impacts_detailed.csv @@ -4,7 +4,7 @@ MI,-113.0947,4228719.0,-478245730.0,,,-113.09 GA,-94.5704,4348380.0,-411227970.0,,,-94.57 MN,-166.80835,2344873.0,-391144400.0,,,-166.81 IL,-61.617107,5187204.0,-319620480.0,,,-61.62 -NY,-28.510832,7896529.0,-225136600.0,,,-28.51 +NY,-28.510836,7896529.0,-225136640.0,,,-28.51 SC,-100.73903,2221951.0,-223837170.0,,,-100.74 NJ,-44.170063,3578201.0,-158049340.0,,,-44.17 MD,-55.2758,2319566.0,-128215890.0,,,-55.28 @@ -23,4 +23,31 @@ HI,-46.590252,500921.0,-23338042.0,,,-46.59 LA,-9.251335,1870034.0,-17300312.0,,,-9.25 MA,-0.35598665,2817993.0,-1003168.0,,,-0.36 KS,-0.040942732,1215639.0,-49772.0,,,-0.04 +PA,0.0,5365676.0,0.0,,,0.0 +TN,0.0,2986816.0,0.0,,,0.0 +OR,0.0,1752219.0,0.0,,,0.0 +TX,0.0,11362365.0,0.0,,,0.0 +UT,0.0,1150286.0,0.0,,,0.0 +WA,0.0,3185000.0,0.0,,,0.0 +WI,0.0,2559938.0,0.0,,,0.0 +SD,0.0,385189.0,0.0,,,0.0 +NV,0.0,1265835.0,0.0,,,0.0 +AK,0.0,275571.0,0.0,,,0.0 +NH,0.0,591239.0,0.0,,,0.0 +AR,0.0,1279007.0,0.0,,,0.0 +AZ,0.0,2941938.0,0.0,,,0.0 +CO,0.0,2440251.0,0.0,,,0.0 +CT,0.0,1503523.0,0.0,,,0.0 +DC,0.0,330109.0,0.0,,,0.0 +DE,0.0,410404.0,0.0,,,0.0 +NM,0.0,882902.0,0.0,,,0.0 +FL,0.0,9323535.0,0.0,,,0.0 +KY,0.0,1886632.0,0.0,,,0.0 +ME,0.0,608698.0,0.0,,,0.0 +MO,0.0,2570655.0,0.0,,,0.0 +MT,0.0,494750.0,0.0,,,0.0 +NC,0.0,4553814.0,0.0,,,0.0 +ND,0.0,338181.0,0.0,,,0.0 +ID,0.0,769370.0,0.0,,,0.0 +WY,0.0,242744.0,0.0,,,0.0 TOTAL,,134260030.0,-5266272000.0,0.0,0.0,-39.224422 From 06519fcb53a1caf2937fa5ac5a96359ab4017313 Mon Sep 17 00:00:00 2001 From: PavelMakarchuk Date: Wed, 4 Dec 2024 18:36:19 -0500 Subject: [PATCH 2/3] add states --- .../repeal_state_dependent_exemptions.ipynb | 419 ++++++------------ .../state_impacts_detailed.csv | 88 ++-- 2 files changed, 189 insertions(+), 318 deletions(-) diff --git a/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb b/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb index 12ebd2f..69e3f46 100644 --- a/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb +++ b/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb @@ -2,9 +2,18 @@ "cells": [ { "cell_type": "code", - "execution_count": 10, + "execution_count": 1, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/Users/pavelmakarchuk/anaconda3/envs/pe/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", + " from .autonotebook import tqdm as notebook_tqdm\n" + ] + } + ], "source": [ "import numpy as np\n", "import pandas as pd\n", @@ -14,7 +23,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ @@ -35,7 +44,27 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "-5546086499.324212" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "difference_income.sum()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, "metadata": {}, "outputs": [], "source": [ @@ -66,7 +95,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -75,59 +104,59 @@ "text": [ "\n", "State-by-State Impact Analysis:\n", - " state_code total_households avg_income_change_per_household total_state_income_impact households_affected percent_households_affected\n", - "4 CA 14365824.0 -161.660004 -2.322313e+09 NaN NaN\n", - "22 MI 4228719.0 -113.089996 -4.782457e+08 NaN NaN\n", - "10 GA 4348380.0 -94.570000 -4.112280e+08 NaN NaN\n", - "23 MN 2344873.0 -166.809998 -3.911444e+08 NaN NaN\n", - "14 IL 5187204.0 -61.619999 -3.196205e+08 NaN NaN\n", - "34 NY 7896529.0 -28.510000 -2.251366e+08 NaN NaN\n", - "40 SC 2221951.0 -100.739998 -2.238372e+08 NaN NaN\n", - "31 NJ 3578201.0 -44.169998 -1.580493e+08 NaN NaN\n", - "20 MD 2319566.0 -55.279999 -1.282159e+08 NaN NaN\n", - "35 OH 4992720.0 -23.680000 -1.182335e+08 NaN NaN\n", - "45 VA 3492310.0 -26.049999 -9.097714e+07 NaN NaN\n", - "29 NE 799766.0 -97.879997 -7.828219e+07 NaN NaN\n", - "15 IN 2804274.0 -18.070000 -5.068625e+07 NaN NaN\n", - "36 OK 1626192.0 -23.270000 -3.784758e+07 NaN NaN\n", - "39 RI 463160.0 -79.510002 -3.682365e+07 NaN NaN\n", - "25 MS 1201572.0 -29.100000 -3.496678e+07 NaN NaN\n", - "46 VT 292460.0 -107.150002 -3.133655e+07 NaN NaN\n", - "12 IA 1364209.0 -22.860001 -3.118891e+07 NaN NaN\n", - "49 WV 750805.0 -39.840000 -2.991399e+07 NaN NaN\n", - "1 AL 2120076.0 -12.520000 -2.653426e+07 NaN NaN\n", - "11 HI 500921.0 -46.590000 -2.333804e+07 NaN NaN\n", - "18 LA 1870034.0 -9.250000 -1.730031e+07 NaN NaN\n", - "19 MA 2817993.0 -0.360000 -1.003168e+06 NaN NaN\n", - "16 KS 1215639.0 -0.040000 -4.977200e+04 NaN NaN\n", - "38 PA 5365676.0 0.000000 0.000000e+00 NaN NaN\n", - "42 TN 2986816.0 0.000000 0.000000e+00 NaN NaN\n", - "37 OR 1752219.0 0.000000 0.000000e+00 NaN NaN\n", - "43 TX 11362365.0 0.000000 0.000000e+00 NaN NaN\n", - "44 UT 1150286.0 0.000000 0.000000e+00 NaN NaN\n", - "47 WA 3185000.0 0.000000 0.000000e+00 NaN NaN\n", - "48 WI 2559938.0 0.000000 0.000000e+00 NaN NaN\n", - "41 SD 385189.0 0.000000 0.000000e+00 NaN NaN\n", - "33 NV 1265835.0 0.000000 0.000000e+00 NaN NaN\n", - "0 AK 275571.0 0.000000 0.000000e+00 NaN NaN\n", - "30 NH 591239.0 0.000000 0.000000e+00 NaN NaN\n", - "2 AR 1279007.0 0.000000 0.000000e+00 NaN NaN\n", - "3 AZ 2941938.0 0.000000 0.000000e+00 NaN NaN\n", - "5 CO 2440251.0 0.000000 0.000000e+00 NaN NaN\n", - "6 CT 1503523.0 0.000000 0.000000e+00 NaN NaN\n", - "7 DC 330109.0 0.000000 0.000000e+00 NaN NaN\n", - "8 DE 410404.0 0.000000 0.000000e+00 NaN NaN\n", - "32 NM 882902.0 0.000000 0.000000e+00 NaN NaN\n", - "9 FL 9323535.0 0.000000 0.000000e+00 NaN NaN\n", - "17 KY 1886632.0 0.000000 0.000000e+00 NaN NaN\n", - "21 ME 608698.0 0.000000 0.000000e+00 NaN NaN\n", - "24 MO 2570655.0 0.000000 0.000000e+00 NaN NaN\n", - "26 MT 494750.0 0.000000 0.000000e+00 NaN NaN\n", - "27 NC 4553814.0 0.000000 0.000000e+00 NaN NaN\n", - "28 ND 338181.0 0.000000 0.000000e+00 NaN NaN\n", - "13 ID 769370.0 0.000000 0.000000e+00 NaN NaN\n", - "50 WY 242744.0 0.000000 0.000000e+00 NaN NaN\n", - "0 TOTAL 134260032.0 -39.224422 -5.266272e+09 0.0 0.0\n" + " state_code total_households avg_income_change_per_household total_state_income_impact\n", + "4 CA 14365824.0 -161.660004 -2322.313\n", + "22 MI 4228719.0 -113.089996 -478.246\n", + "10 GA 4348380.0 -94.570000 -411.228\n", + "23 MN 2344873.0 -166.809998 -391.144\n", + "14 IL 5187204.0 -61.880001 -320.991\n", + "34 NY 7896529.0 -28.510000 -225.137\n", + "40 SC 2221951.0 -100.739998 -223.837\n", + "31 NJ 3578201.0 -44.169998 -158.049\n", + "20 MD 2319566.0 -55.279999 -128.216\n", + "35 OH 4992720.0 -23.680000 -118.233\n", + "27 NC 4553814.0 -20.290001 -92.384\n", + "45 VA 3492310.0 -26.049999 -90.977\n", + "29 NE 799766.0 -97.879997 -78.282\n", + "44 UT 1150286.0 -63.840000 -73.437\n", + "15 IN 2804274.0 -18.070000 -50.686\n", + "48 WI 2559938.0 -17.730000 -45.393\n", + "26 MT 494750.0 -86.000000 -42.550\n", + "36 OK 1626192.0 -23.270000 -37.848\n", + "39 RI 463160.0 -79.510002 -36.824\n", + "25 MS 1201572.0 -29.100000 -34.967\n", + "46 VT 292460.0 -107.150002 -31.337\n", + "12 IA 1364209.0 -22.860001 -31.189\n", + "49 WV 750805.0 -39.840000 -29.914\n", + "1 AL 2120076.0 -12.520000 -26.534\n", + "32 NM 882902.0 -27.950001 -24.679\n", + "11 HI 500921.0 -46.590000 -23.338\n", + "18 LA 1870034.0 -9.250000 -17.300\n", + "19 MA 2817993.0 -0.360000 -1.003\n", + "16 KS 1215639.0 -0.040000 -0.050\n", + "43 TX 11362365.0 0.000000 0.000\n", + "47 WA 3185000.0 0.000000 0.000\n", + "37 OR 1752219.0 0.000000 0.000\n", + "41 SD 385189.0 0.000000 0.000\n", + "42 TN 2986816.0 0.000000 0.000\n", + "38 PA 5365676.0 0.000000 0.000\n", + "0 AK 275571.0 0.000000 0.000\n", + "30 NH 591239.0 0.000000 0.000\n", + "28 ND 338181.0 0.000000 0.000\n", + "24 MO 2570655.0 0.000000 0.000\n", + "21 ME 608698.0 0.000000 0.000\n", + "17 KY 1886632.0 0.000000 0.000\n", + "13 ID 769370.0 0.000000 0.000\n", + "9 FL 9323535.0 0.000000 0.000\n", + "8 DE 410404.0 0.000000 0.000\n", + "7 DC 330109.0 0.000000 0.000\n", + "6 CT 1503523.0 0.000000 0.000\n", + "5 CO 2440251.0 0.000000 0.000\n", + "3 AZ 2941938.0 0.000000 0.000\n", + "2 AR 1279007.0 0.000000 0.000\n", + "33 NV 1265835.0 0.000000 0.000\n", + "50 WY 242744.0 0.000000 0.000\n", + "0 TOTAL 134260032.0 -0.000041 -5546.086\n" ] } ], @@ -159,7 +188,7 @@ "\n", "# Format the results\n", "state_impacts['avg_income_change'] = state_impacts['income_change'].round(2)\n", - "state_impacts['total_income_impact'] = state_impacts['total_income_impact'].round(0)\n", + "state_impacts['total_income_impact'] = (state_impacts['total_income_impact'] / 1_000_000).round(3)\n", "state_impacts['households_affected'] = state_impacts['households_affected'].round(0)\n", "state_impacts['percent_households_affected'] = state_impacts['percent_households_affected'].round(2)\n", "state_impacts['weight'] = state_impacts['weight'].round(0)\n", @@ -180,10 +209,7 @@ " 'total_households': [state_impacts_sorted['total_households'].sum()],\n", " 'avg_income_change_per_household': [(state_impacts_sorted['total_state_income_impact'].sum() / \n", " state_impacts_sorted['total_households'].sum())],\n", - " 'total_state_income_impact': [state_impacts_sorted['total_state_income_impact'].sum()],\n", - " 'households_affected': [state_impacts_sorted['households_affected'].sum()],\n", - " 'percent_households_affected': [(state_impacts_sorted['households_affected'].sum() / \n", - " state_impacts_sorted['total_households'].sum() * 100)]\n", + " 'total_state_income_impact': [state_impacts_sorted['total_state_income_impact'].sum()]\n", "})\n", "\n", "# Combine state results with national totals\n", @@ -195,15 +221,13 @@ " 'state_code',\n", " 'total_households',\n", " 'avg_income_change_per_household',\n", - " 'total_state_income_impact',\n", - " 'households_affected',\n", - " 'percent_households_affected'\n", + " 'total_state_income_impact'\n", "]].to_string())" ] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 6, "metadata": {}, "outputs": [], "source": [ @@ -212,165 +236,7 @@ }, { "cell_type": "code", - "execution_count": 43, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\n", - "State-by-State Analysis of Children in Households with Zero State Exemptions:\n", - " state_code children_in_zero_exemption percent_children_in_zero_exemption\n", - "0 AK 183148.0 100.00\n", - "1 AL 0.0 0.00\n", - "2 AR 674473.0 100.00\n", - "3 AZ 1462527.0 100.00\n", - "4 CA 142232.0 1.85\n", - "5 CO 1192968.0 100.00\n", - "6 CT 688379.0 100.00\n", - "7 DC 96332.0 100.00\n", - "8 DE 218417.0 100.00\n", - "9 FL 4147576.0 100.00\n", - "10 GA 0.0 0.00\n", - "11 HI 0.0 0.00\n", - "12 IA 807211.0 100.00\n", - "13 ID 503665.0 100.00\n", - "14 IL 0.0 0.00\n", - "15 IN 0.0 0.00\n", - "16 KS 0.0 0.00\n", - "17 KY 1014111.0 100.00\n", - "18 LA 0.0 0.00\n", - "19 MA 1358035.0 100.00\n", - "20 MD 266472.0 20.70\n", - "21 ME 233492.0 100.00\n", - "22 MI 0.0 0.00\n", - "23 MN 39231.0 3.05\n", - "24 MO 1491649.0 100.00\n", - "25 MS 0.0 0.00\n", - "26 MT 244193.0 100.00\n", - "27 NC 2249389.0 100.00\n", - "28 ND 193633.0 100.00\n", - "29 NE 0.0 0.00\n", - "30 NH 268315.0 100.00\n", - "31 NJ 0.0 0.00\n", - "32 NM 460692.0 100.00\n", - "33 NV 673834.0 100.00\n", - "34 NY 0.0 0.00\n", - "35 OH 204579.0 8.06\n", - "36 OK 0.0 0.00\n", - "37 OR 857949.0 100.00\n", - "38 PA 2522785.0 100.00\n", - "39 RI 17859.0 8.52\n", - "40 SC 0.0 0.00\n", - "41 SD 211732.0 100.00\n", - "42 TN 1510758.0 100.00\n", - "43 TX 7005304.0 100.00\n", - "44 UT 943211.0 100.00\n", - "45 VA 0.0 0.00\n", - "46 VT 0.0 0.00\n", - "47 WA 1706458.0 100.00\n", - "48 WI 1360253.0 100.00\n", - "49 WV 0.0 0.00\n", - "50 WY 138867.0 100.00\n" - ] - } - ], - "source": [ - "# Calculate household income and number of children\n", - "household_income = baseline.calculate(\"household_net_income\", period=2024)\n", - "num_children = baseline.calculate(\"tax_unit_children\", map_to='household', period=2024)\n", - "# Create a mapping of state codes to their exemption variables\n", - "state_to_exemption = {\n", - " 'AL': ['al_personal_exemption'],\n", - " 'CA': ['ca_exemptions'],\n", - " 'GA': ['ga_exemptions'],\n", - " 'HI': ['hi_exemptions'],\n", - " 'IN': ['in_base_exemptions'],\n", - " 'IL': ['il_dependent_exemption'],\n", - " 'KS': ['ks_exemptions'],\n", - " 'LA': ['la_dependents_exemption'],\n", - " 'MD': ['md_total_personal_exemptions'],\n", - " 'MI': ['mi_exemptions'],\n", - " 'MN': ['mn_exemptions'],\n", - " 'MS': ['ms_dependents_exemption'],\n", - " 'NE': ['ne_exemptions'],\n", - " 'NJ': ['nj_dependents_exemption'],\n", - " 'NY': ['ny_exemptions'],\n", - " 'OH': ['oh_personal_exemptions'],\n", - " 'OK': ['ok_exemptions'],\n", - " 'RI': ['ri_exemptions'],\n", - " 'SC': ['sc_dependent_exemption'],\n", - " 'VA': ['va_personal_exemption'],\n", - " 'VT': ['vt_personal_exemptions'],\n", - " 'WV': ['wv_personal_exemption']\n", - "}\n", - "\n", - "# Calculate exemptions state by state\n", - "total_exemptions = np.zeros_like(household_income)\n", - "state_codes = baseline.calculate(\"state_code\", period=2024)\n", - "\n", - "# Add debug prints\n", - "for state, exemption_list in state_to_exemption.items():\n", - " state_mask = (state_codes == state)\n", - " state_exemptions = np.zeros_like(household_income)\n", - " \n", - " for var in exemption_list:\n", - " try:\n", - " # Map tax unit variables to household level\n", - " exemption_value = baseline.calculate(var, map_to=\"household\", period=2024)\n", - " state_exemptions += exemption_value\n", - " except Exception as e:\n", - " continue\n", - " \n", - " total_exemptions[state_mask] = state_exemptions[state_mask]\n", - "\n", - "\n", - "\n", - "\n", - "results_df['total_children'] = num_children\n", - "\n", - "\n", - "# Identify children in households with zero exemptions\n", - "children_in_zero_exemption = (total_exemptions == 0).astype(int) * num_children\n", - "# Add to results DataFrame\n", - "results_df['children_in_zero_exemption'] = children_in_zero_exemption\n", - "\n", - "# Get household weights for accurate aggregation\n", - "weights = baseline.calculate(\"household_weight\", period=2024)\n", - "results_df['weight'] = weights\n", - "\n", - "# Calculate state-level statistics with weights\n", - "state_children_impact = (\n", - " results_df\n", - " .groupby('state_code')\n", - " .agg({\n", - " 'children_in_zero_exemption': lambda x: np.sum(x * results_df.loc[x.index, 'weight']),\n", - " 'total_children': lambda x: np.sum(x * results_df.loc[x.index, 'weight'])\n", - " })\n", - " .reset_index()\n", - ")\n", - "\n", - "# Calculate percentage using total children as denominator\n", - "state_children_impact['percent_children_in_zero_exemption'] = (\n", - " state_children_impact['children_in_zero_exemption'] / state_children_impact['total_children'] * 100\n", - ")\n", - "\n", - "# Format and display results\n", - "state_children_impact['children_in_zero_exemption'] = state_children_impact['children_in_zero_exemption'].round(0)\n", - "state_children_impact['percent_children_in_zero_exemption'] = state_children_impact['percent_children_in_zero_exemption'].round(2)\n", - "\n", - "print(\"\\nState-by-State Analysis of Children in Households with Zero State Exemptions:\")\n", - "print(state_children_impact[[\n", - " 'state_code',\n", - " 'children_in_zero_exemption',\n", - " 'percent_children_in_zero_exemption'\n", - "]].to_string())" - ] - }, - { - "cell_type": "code", - "execution_count": 58, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -378,31 +244,37 @@ "output_type": "stream", "text": [ "\n", - "Children in households with zero tax in both scenarios (unweighted):\n", + "Children in households with zero tax in both scenarios (weighted):\n", " state_code total_children children_zero_tax percent_zero_tax\n", - "16 OK 1,849.0 1,090.0 59.0\n", - "21 VT 1,154.0 676.0 58.6\n", - "14 NY 3,629.0 2,029.0 55.9\n", - "13 NJ 2,013.0 1,100.0 54.6\n", - "19 TX 7,333.0 3,984.0 54.3\n", - "17 RI 823.0 408.0 49.6\n", - "22 WV 1,968.0 938.0 47.7\n", - "3 HI 1,649.0 783.0 47.5\n", - "8 MD 1,272.0 581.0 45.7\n", - "10 MN 1,574.0 716.0 45.5\n", - "2 GA 2,386.0 1,063.0 44.6\n", - "20 VA 2,098.0 932.0 44.4\n", - "1 CA 9,521.0 4,179.0 43.9\n", - "7 LA 2,549.0 1,108.0 43.5\n", - "9 MI 2,457.0 984.0 40.0\n", - "12 NE 1,546.0 615.0 39.8\n", - "11 MS 1,819.0 656.0 36.1\n", - "18 SC 1,913.0 672.0 35.1\n", - "4 IL 3,003.0 1,054.0 35.1\n", - "0 AL 2,136.0 723.0 33.8\n", - "15 OH 2,476.0 801.0 32.4\n", - "6 KS 1,543.0 444.0 28.8\n", - "5 IN 1,946.0 500.0 25.7\n" + "23 TX 7,005,303.5 7,005,303.5 100.0\n", + "22 SC 1,179,198.5 380,843.5 32.3\n", + "19 OH 2,536,852.3 665,523.0 26.2\n", + "17 NM 460,692.2 118,240.1 25.7\n", + "2 GA 2,362,779.7 471,650.4 20.0\n", + "6 KS 724,014.4 133,655.5 18.5\n", + "28 WV 378,390.8 68,815.4 18.2\n", + "24 UT 943,210.6 172,035.9 18.2\n", + "12 MS 628,728.5 114,058.6 18.1\n", + "1 CA 7,696,760.0 1,359,631.5 17.7\n", + "20 OK 959,907.1 152,208.6 15.9\n", + "9 MD 1,287,321.9 192,272.0 14.9\n", + "7 LA 1,041,173.6 114,304.2 11.0\n", + "27 WI 1,360,253.0 146,958.6 10.8\n", + "0 AL 998,394.1 106,533.3 10.7\n", + "25 VA 1,844,934.6 184,340.6 10.0\n", + "18 NY 3,695,491.9 332,216.9 9.0\n", + "26 VT 121,618.4 10,722.6 8.8\n", + "21 RI 209,629.1 14,628.7 7.0\n", + "3 HI 293,633.5 19,959.7 6.8\n", + "8 MA 1,358,034.5 89,393.4 6.6\n", + "11 MN 1,286,774.4 83,057.4 6.5\n", + "10 MI 2,146,789.0 137,368.6 6.4\n", + "15 NE 506,348.8 23,372.9 4.6\n", + "5 IN 1,694,145.8 60,501.0 3.6\n", + "16 NJ 1,897,915.1 65,022.0 3.4\n", + "13 MT 244,193.4 8,082.5 3.3\n", + "4 IL 2,708,379.5 0.0 0.0\n", + "14 NC 2,249,389.3 0.0 0.0\n" ] } ], @@ -415,18 +287,22 @@ " 'KS': ['ks_exemptions'], 'LA': ['la_dependents_exemption'],\n", " 'MD': ['md_total_personal_exemptions'], 'MI': ['mi_exemptions'],\n", " 'MN': ['mn_exemptions'], 'MS': ['ms_dependents_exemption'],\n", + " 'MT': ['mt_dependent_exemptions_person'], 'MA': ['ma_income_tax_exemption_threshold'],\n", + " 'NC': ['nc_child_deduction'], 'NM': ['nm_deduction_for_certain_dependents'],\n", " 'NE': ['ne_exemptions'], 'NJ': ['nj_dependents_exemption'],\n", " 'NY': ['ny_exemptions'], 'OH': ['oh_personal_exemptions'],\n", " 'OK': ['ok_exemptions'], 'RI': ['ri_exemptions'],\n", - " 'SC': ['sc_dependent_exemption'], 'VA': ['va_personal_exemption'],\n", - " 'VT': ['vt_personal_exemptions'], 'WV': ['wv_personal_exemption']\n", + " 'SC': ['sc_dependent_exemption'], 'UT': ['ut_exemptions'],\n", + " 'VA': ['va_personal_exemption'],\n", + " 'VT': ['vt_personal_exemptions'], 'WI': ['wi_exemptions'],\n", + " 'WV': ['wv_personal_exemption']\n", "}\n", "\n", "# Get required variables\n", "state_codes = baseline.calculate(\"state_code\", period=2024)\n", "num_children = baseline.calculate(\"tax_unit_children\", map_to='household', period=2024)\n", - "baseline_tax = baseline.calculate(\"state_income_tax_before_refundable_credits\", period=2024)\n", - "reformed_tax = reformed.calculate(\"state_income_tax_before_refundable_credits\", period=2024)\n", + "baseline_tax = baseline.calculate(\"state_income_tax_before_refundable_credits\", map_to='household', period=2024)\n", + "reformed_tax = reformed.calculate(\"state_income_tax_before_refundable_credits\", map_to='household', period=2024)\n", "\n", "# Create results DataFrame\n", "results = pd.DataFrame({\n", @@ -439,44 +315,39 @@ "states_to_show = list(state_to_exemption.keys()) + ['TX']\n", "results = results[results['state_code'].isin(states_to_show)]\n", "\n", - "# Calculate total children by state (unweighted)\n", + "# Get household weights\n", + "weights = baseline.calculate(\"household_weight\", period=2024)\n", + "\n", + "# Add weights to results DataFrame\n", + "results['weight'] = weights\n", + "\n", + "# Calculate weighted total children by state\n", "total_children = (\n", " results\n", " .groupby('state_code')\n", - " ['num_children']\n", - " .sum()\n", + " .apply(lambda x: np.sum(x['num_children'] * x['weight']))\n", " .reset_index(name='total_children')\n", ")\n", "\n", - "# Calculate children with zero tax in both scenarios (unweighted)\n", + "# Calculate weighted children with zero tax in both scenarios\n", "zero_tax_children = (\n", " results[results['zero_tax_both']]\n", " .groupby('state_code')\n", - " ['num_children']\n", - " .sum()\n", + " .apply(lambda x: np.sum(x['num_children'] * x['weight']))\n", " .reset_index(name='children_zero_tax')\n", ")\n", "\n", - "# Merge results\n", - "state_results = total_children.merge(zero_tax_children, on='state_code', how='left').fillna(0)\n", - "\n", - "# Calculate percentage\n", + "# Rest of the code remains the same\n", + "state_results = total_children.merge(zero_tax_children, on='state_code', how='left')\n", "state_results['percent_zero_tax'] = (\n", " state_results['children_zero_tax'] / state_results['total_children'] * 100\n", ").round(1)\n", "\n", - "# Sort and display results\n", "state_results = state_results.sort_values('percent_zero_tax', ascending=False)\n", - "print(\"\\nChildren in households with zero tax in both scenarios (unweighted):\")\n", - "print(state_results.to_string(float_format=lambda x: f\"{x:,.1f}\"))" + "print(\"\\nChildren in households with zero tax in both scenarios (weighted):\")\n", + "print(state_results.to_string(float_format=lambda x: f\"{x:,.1f}\"))\n", + "\n" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": { diff --git a/us/state_dependent_exemptions/state_impacts_detailed.csv b/us/state_dependent_exemptions/state_impacts_detailed.csv index 91c13fc..9584023 100644 --- a/us/state_dependent_exemptions/state_impacts_detailed.csv +++ b/us/state_dependent_exemptions/state_impacts_detailed.csv @@ -1,53 +1,53 @@ state_code,income_change,total_households,total_state_income_impact,households_affected,percent_households_affected,avg_income_change_per_household -CA,-161.65538,14365824.0,-2322312700.0,,,-161.66 -MI,-113.0947,4228719.0,-478245730.0,,,-113.09 -GA,-94.5704,4348380.0,-411227970.0,,,-94.57 -MN,-166.80835,2344873.0,-391144400.0,,,-166.81 -IL,-61.617107,5187204.0,-319620480.0,,,-61.62 -NY,-28.510836,7896529.0,-225136640.0,,,-28.51 -SC,-100.73903,2221951.0,-223837170.0,,,-100.74 -NJ,-44.170063,3578201.0,-158049340.0,,,-44.17 -MD,-55.2758,2319566.0,-128215890.0,,,-55.28 -OH,-23.681173,4992720.0,-118233464.0,,,-23.68 -VA,-26.05071,3492310.0,-90977144.0,,,-26.05 -NE,-97.881355,799766.0,-78282190.0,,,-97.88 -IN,-18.07464,2804274.0,-50686250.0,,,-18.07 -OK,-23.273746,1626192.0,-37847576.0,,,-23.27 -RI,-79.50533,463160.0,-36823652.0,,,-79.51 -MS,-29.100868,1201572.0,-34966784.0,,,-29.1 -VT,-107.14814,292460.0,-31336546.0,,,-107.15 -IA,-22.862263,1364209.0,-31188908.0,,,-22.86 -WV,-39.842545,750805.0,-29913988.0,,,-39.84 -AL,-12.515711,2120076.0,-26534264.0,,,-12.52 -HI,-46.590252,500921.0,-23338042.0,,,-46.59 -LA,-9.251335,1870034.0,-17300312.0,,,-9.25 -MA,-0.35598665,2817993.0,-1003168.0,,,-0.36 -KS,-0.040942732,1215639.0,-49772.0,,,-0.04 -PA,0.0,5365676.0,0.0,,,0.0 -TN,0.0,2986816.0,0.0,,,0.0 -OR,0.0,1752219.0,0.0,,,0.0 +CA,-161.65538,14365824.0,-2322.313,,,-161.66000366210938 +MI,-113.0947,4228719.0,-478.246,,,-113.08999633789062 +GA,-94.5704,4348380.0,-411.228,,,-94.56999969482422 +MN,-166.80835,2344873.0,-391.144,,,-166.80999755859375 +IL,-61.881397,5187204.0,-320.991,,,-61.880001068115234 +NY,-28.510836,7896529.0,-225.137,,,-28.510000228881836 +SC,-100.73903,2221951.0,-223.837,,,-100.73999786376953 +NJ,-44.170063,3578201.0,-158.049,,,-44.16999816894531 +MD,-55.2758,2319566.0,-128.216,,,-55.279998779296875 +OH,-23.681173,4992720.0,-118.233,,,-23.68000030517578 +NC,-20.287275,4553814.0,-92.384,,,-20.290000915527344 +VA,-26.05071,3492310.0,-90.977,,,-26.049999237060547 +NE,-97.881355,799766.0,-78.282,,,-97.87999725341797 +UT,-63.841988,1150286.0,-73.437,,,-63.84000015258789 +IN,-18.07464,2804274.0,-50.686,,,-18.06999969482422 +WI,-17.732164,2559938.0,-45.393,,,-17.729999542236328 +MT,-86.0032,494750.0,-42.55,,,-86.0 +OK,-23.273746,1626192.0,-37.848,,,-23.270000457763672 +RI,-79.50533,463160.0,-36.824,,,-79.51000213623047 +MS,-29.100868,1201572.0,-34.967,,,-29.100000381469727 +VT,-107.14814,292460.0,-31.337,,,-107.1500015258789 +IA,-22.862263,1364209.0,-31.189,,,-22.860000610351562 +WV,-39.842545,750805.0,-29.914,,,-39.84000015258789 +AL,-12.515711,2120076.0,-26.534,,,-12.520000457763672 +NM,-27.952093,882902.0,-24.679,,,-27.950000762939453 +HI,-46.590252,500921.0,-23.338,,,-46.59000015258789 +LA,-9.251335,1870034.0,-17.3,,,-9.25 +MA,-0.35598665,2817993.0,-1.003,,,-0.36000001430511475 +KS,-0.040942732,1215639.0,-0.05,,,-0.03999999910593033 TX,0.0,11362365.0,0.0,,,0.0 -UT,0.0,1150286.0,0.0,,,0.0 WA,0.0,3185000.0,0.0,,,0.0 -WI,0.0,2559938.0,0.0,,,0.0 +OR,0.0,1752219.0,0.0,,,0.0 SD,0.0,385189.0,0.0,,,0.0 -NV,0.0,1265835.0,0.0,,,0.0 +TN,0.0,2986816.0,0.0,,,0.0 +PA,0.0,5365676.0,0.0,,,0.0 AK,0.0,275571.0,0.0,,,0.0 NH,0.0,591239.0,0.0,,,0.0 -AR,0.0,1279007.0,0.0,,,0.0 -AZ,0.0,2941938.0,0.0,,,0.0 -CO,0.0,2440251.0,0.0,,,0.0 -CT,0.0,1503523.0,0.0,,,0.0 -DC,0.0,330109.0,0.0,,,0.0 -DE,0.0,410404.0,0.0,,,0.0 -NM,0.0,882902.0,0.0,,,0.0 -FL,0.0,9323535.0,0.0,,,0.0 -KY,0.0,1886632.0,0.0,,,0.0 -ME,0.0,608698.0,0.0,,,0.0 -MO,0.0,2570655.0,0.0,,,0.0 -MT,0.0,494750.0,0.0,,,0.0 -NC,0.0,4553814.0,0.0,,,0.0 ND,0.0,338181.0,0.0,,,0.0 +MO,0.0,2570655.0,0.0,,,0.0 +ME,0.0,608698.0,0.0,,,0.0 +KY,0.0,1886632.0,0.0,,,0.0 ID,0.0,769370.0,0.0,,,0.0 +FL,0.0,9323535.0,0.0,,,0.0 +DE,0.0,410404.0,0.0,,,0.0 +DC,0.0,330109.0,0.0,,,0.0 +CT,0.0,1503523.0,0.0,,,0.0 +CO,0.0,2440251.0,0.0,,,0.0 +AZ,0.0,2941938.0,0.0,,,0.0 +AR,0.0,1279007.0,0.0,,,0.0 +NV,0.0,1265835.0,0.0,,,0.0 WY,0.0,242744.0,0.0,,,0.0 -TOTAL,,134260030.0,-5266272000.0,0.0,0.0,-39.224422 +TOTAL,,134260030.0,-5546.086,,,-4.130854072789138e-05 From ec23ebf579db3e9b78105caa2e0160ca02215442 Mon Sep 17 00:00:00 2001 From: PavelMakarchuk Date: Wed, 18 Dec 2024 18:20:48 -0500 Subject: [PATCH 3/3] nuance --- .../repeal_state_dependent_exemptions.ipynb | 232 +++++++++--------- .../state_impacts_detailed.csv | 104 ++++---- 2 files changed, 171 insertions(+), 165 deletions(-) diff --git a/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb b/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb index 69e3f46..b2c8a7e 100644 --- a/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb +++ b/us/state_dependent_exemptions/repeal_state_dependent_exemptions.ipynb @@ -30,15 +30,15 @@ "\n", "reform = Reform.from_dict({\n", " \"gov.contrib.repeal_state_dependent_exemptions.in_effect\": {\n", - " \"2024-01-01.2100-12-31\": True\n", + " \"2025-01-01.2100-12-31\": True\n", " }\n", "}, country_id=\"us\")\n", "\n", "\n", "baseline = Microsimulation(dataset='pooled_3_year_cps_2023')\n", "reformed = Microsimulation(reform=reform, dataset='pooled_3_year_cps_2023')\n", - "baseline_income = baseline.calculate(\"household_net_income\", period=2024)\n", - "reformed_income = reformed.calculate(\"household_net_income\", period=2024)\n", + "baseline_income = baseline.calculate(\"household_net_income\", period=2025)\n", + "reformed_income = reformed.calculate(\"household_net_income\", period=2025)\n", "difference_income = reformed_income - baseline_income" ] }, @@ -50,7 +50,7 @@ { "data": { "text/plain": [ - "-5546086499.324212" + "-6091587854.847457" ] }, "execution_count": 3, @@ -69,10 +69,10 @@ "outputs": [], "source": [ "# Get state codes\n", - "state_code = baseline.calculate(\"state_code\", period=2024)\n", + "state_code = baseline.calculate(\"state_code\", period=2025)\n", "\n", "# Get household weights for accurate aggregation\n", - "weights = baseline.calculate(\"household_weight\", period=2024)\n", + "weights = baseline.calculate(\"household_weight\", period=2025)\n", "\n", "# Create a DataFrame with the results\n", "results_df = pd.DataFrame({\n", @@ -105,58 +105,58 @@ "\n", "State-by-State Impact Analysis:\n", " state_code total_households avg_income_change_per_household total_state_income_impact\n", - "4 CA 14365824.0 -161.660004 -2322.313\n", - "22 MI 4228719.0 -113.089996 -478.246\n", - "10 GA 4348380.0 -94.570000 -411.228\n", - "23 MN 2344873.0 -166.809998 -391.144\n", - "14 IL 5187204.0 -61.880001 -320.991\n", - "34 NY 7896529.0 -28.510000 -225.137\n", - "40 SC 2221951.0 -100.739998 -223.837\n", - "31 NJ 3578201.0 -44.169998 -158.049\n", - "20 MD 2319566.0 -55.279999 -128.216\n", - "35 OH 4992720.0 -23.680000 -118.233\n", - "27 NC 4553814.0 -20.290001 -92.384\n", - "45 VA 3492310.0 -26.049999 -90.977\n", - "29 NE 799766.0 -97.879997 -78.282\n", - "44 UT 1150286.0 -63.840000 -73.437\n", - "15 IN 2804274.0 -18.070000 -50.686\n", - "48 WI 2559938.0 -17.730000 -45.393\n", - "26 MT 494750.0 -86.000000 -42.550\n", - "36 OK 1626192.0 -23.270000 -37.848\n", - "39 RI 463160.0 -79.510002 -36.824\n", - "25 MS 1201572.0 -29.100000 -34.967\n", - "46 VT 292460.0 -107.150002 -31.337\n", - "12 IA 1364209.0 -22.860001 -31.189\n", - "49 WV 750805.0 -39.840000 -29.914\n", - "1 AL 2120076.0 -12.520000 -26.534\n", - "32 NM 882902.0 -27.950001 -24.679\n", - "11 HI 500921.0 -46.590000 -23.338\n", - "18 LA 1870034.0 -9.250000 -17.300\n", - "19 MA 2817993.0 -0.360000 -1.003\n", - "16 KS 1215639.0 -0.040000 -0.050\n", - "43 TX 11362365.0 0.000000 0.000\n", - "47 WA 3185000.0 0.000000 0.000\n", - "37 OR 1752219.0 0.000000 0.000\n", - "41 SD 385189.0 0.000000 0.000\n", - "42 TN 2986816.0 0.000000 0.000\n", - "38 PA 5365676.0 0.000000 0.000\n", - "0 AK 275571.0 0.000000 0.000\n", - "30 NH 591239.0 0.000000 0.000\n", - "28 ND 338181.0 0.000000 0.000\n", - "24 MO 2570655.0 0.000000 0.000\n", - "21 ME 608698.0 0.000000 0.000\n", - "17 KY 1886632.0 0.000000 0.000\n", - "13 ID 769370.0 0.000000 0.000\n", - "9 FL 9323535.0 0.000000 0.000\n", - "8 DE 410404.0 0.000000 0.000\n", - "7 DC 330109.0 0.000000 0.000\n", - "6 CT 1503523.0 0.000000 0.000\n", - "5 CO 2440251.0 0.000000 0.000\n", - "3 AZ 2941938.0 0.000000 0.000\n", - "2 AR 1279007.0 0.000000 0.000\n", - "33 NV 1265835.0 0.000000 0.000\n", - "50 WY 242744.0 0.000000 0.000\n", - "0 TOTAL 134260032.0 -0.000041 -5546.086\n" + "4 CA 14531141.0 -168.119995 -2442.917\n", + "22 MI 4277382.0 -113.279999 -484.533\n", + "10 GA 4398419.0 -94.610001 -416.124\n", + "23 MN 2371857.0 -172.839996 -409.952\n", + "14 IL 5246896.0 -61.740002 -323.962\n", + "34 NY 7987400.0 -28.860001 -230.489\n", + "40 SC 2247520.0 -101.629997 -228.414\n", + "31 NJ 3619377.0 -45.480000 -164.620\n", + "20 MD 2346259.0 -53.090000 -124.572\n", + "35 OH 5050174.0 -24.020000 -121.291\n", + "3 AZ 2975793.0 -35.650002 -106.090\n", + "45 VA 3532498.0 -26.370001 -93.138\n", + "27 NC 4606217.0 -18.680000 -86.054\n", + "44 UT 1163523.0 -70.320000 -81.815\n", + "13 ID 778224.0 -105.120003 -81.810\n", + "29 NE 808970.0 -101.089996 -81.779\n", + "21 ME 615702.0 -130.309998 -80.230\n", + "36 OK 1644905.0 -47.430000 -78.016\n", + "15 IN 2836545.0 -17.780001 -50.446\n", + "48 WI 2589397.0 -17.920000 -46.391\n", + "26 MT 500444.0 -86.610001 -43.344\n", + "39 RI 468489.0 -82.699997 -38.743\n", + "17 KY 1908343.0 -19.610001 -37.423\n", + "25 MS 1215399.0 -27.450001 -33.367\n", + "46 VT 295826.0 -111.870003 -33.095\n", + "12 IA 1379908.0 -22.940001 -31.649\n", + "49 WV 759445.0 -40.330002 -30.626\n", + "1 AL 2144474.0 -12.310000 -26.406\n", + "32 NM 893062.0 -28.639999 -25.582\n", + "8 DE 415126.0 -51.410000 -21.344\n", + "11 HI 506686.0 -40.430000 -20.484\n", + "2 AR 1293726.0 -12.240000 -15.839\n", + "19 MA 2850422.0 -0.350000 -0.994\n", + "16 KS 1229628.0 -0.040000 -0.050\n", + "43 TX 11493119.0 0.000000 0.000\n", + "42 TN 3021187.0 0.000000 0.000\n", + "41 SD 389622.0 0.000000 0.000\n", + "47 WA 3221652.0 0.000000 0.000\n", + "0 AK 278742.0 0.000000 0.000\n", + "37 OR 1772383.0 0.000000 0.000\n", + "33 NV 1280402.0 0.000000 0.000\n", + "30 NH 598043.0 0.000000 0.000\n", + "28 ND 342073.0 0.000000 0.000\n", + "24 MO 2600237.0 0.000000 0.000\n", + "18 LA 1891554.0 0.000000 0.000\n", + "9 FL 9430827.0 0.000000 0.000\n", + "7 DC 333908.0 0.000000 0.000\n", + "6 CT 1520825.0 0.000000 0.000\n", + "5 CO 2468332.0 0.000000 0.000\n", + "38 PA 5427422.0 0.000000 0.000\n", + "50 WY 245537.0 0.000000 0.000\n", + "0 TOTAL 135805040.0 -0.000045 -6091.589\n" ] } ], @@ -236,7 +236,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -246,61 +246,64 @@ "\n", "Children in households with zero tax in both scenarios (weighted):\n", " state_code total_children children_zero_tax percent_zero_tax\n", - "23 TX 7,005,303.5 7,005,303.5 100.0\n", - "22 SC 1,179,198.5 380,843.5 32.3\n", - "19 OH 2,536,852.3 665,523.0 26.2\n", - "17 NM 460,692.2 118,240.1 25.7\n", - "2 GA 2,362,779.7 471,650.4 20.0\n", - "6 KS 724,014.4 133,655.5 18.5\n", - "28 WV 378,390.8 68,815.4 18.2\n", - "24 UT 943,210.6 172,035.9 18.2\n", - "12 MS 628,728.5 114,058.6 18.1\n", - "1 CA 7,696,760.0 1,359,631.5 17.7\n", - "20 OK 959,907.1 152,208.6 15.9\n", - "9 MD 1,287,321.9 192,272.0 14.9\n", - "7 LA 1,041,173.6 114,304.2 11.0\n", - "27 WI 1,360,253.0 146,958.6 10.8\n", - "0 AL 998,394.1 106,533.3 10.7\n", - "25 VA 1,844,934.6 184,340.6 10.0\n", - "18 NY 3,695,491.9 332,216.9 9.0\n", - "26 VT 121,618.4 10,722.6 8.8\n", - "21 RI 209,629.1 14,628.7 7.0\n", - "3 HI 293,633.5 19,959.7 6.8\n", - "8 MA 1,358,034.5 89,393.4 6.6\n", - "11 MN 1,286,774.4 83,057.4 6.5\n", - "10 MI 2,146,789.0 137,368.6 6.4\n", - "15 NE 506,348.8 23,372.9 4.6\n", - "5 IN 1,694,145.8 60,501.0 3.6\n", - "16 NJ 1,897,915.1 65,022.0 3.4\n", - "13 MT 244,193.4 8,082.5 3.3\n", - "4 IL 2,708,379.5 0.0 0.0\n", - "14 NC 2,249,389.3 0.0 0.0\n" + "2 AR 674,472.9 190,476.5 28.2\n", + "32 NM 460,692.2 129,421.1 28.1\n", + "18 LA 1,041,173.6 287,304.2 27.6\n", + "25 MS 628,728.5 168,819.7 26.9\n", + "1 AL 998,394.1 268,625.9 26.9\n", + "17 KY 1,014,110.9 254,769.5 25.1\n", + "36 OK 959,907.1 240,113.7 25.0\n", + "49 WV 378,390.8 87,248.9 23.1\n", + "40 SC 1,179,198.5 264,245.2 22.4\n", + "27 NC 2,249,389.3 500,394.7 22.2\n", + "43 TX 7,005,303.5 1,511,229.6 21.6\n", + "3 AZ 1,462,526.9 302,195.0 20.7\n", + "7 DC 96,331.9 19,736.5 20.5\n", + "33 NV 673,833.6 137,448.7 20.4\n", + "10 GA 2,362,779.7 472,573.8 20.0\n", + "22 MI 2,146,789.0 426,595.4 19.9\n", + "9 FL 4,147,576.2 820,765.7 19.8\n", + "8 DE 218,417.0 42,714.4 19.6\n", + "34 NY 3,695,491.9 722,195.4 19.5\n", + "21 ME 233,491.6 43,915.7 18.8\n", + "38 PA 2,522,784.9 470,198.3 18.6\n", + "35 OH 2,536,852.3 469,208.6 18.5\n", + "24 MO 1,491,649.4 274,968.5 18.4\n", + "16 KS 724,014.4 126,574.0 17.5\n", + "4 CA 7,696,760.0 1,327,456.8 17.2\n", + "42 TN 1,510,758.1 253,839.9 16.8\n", + "11 HI 293,633.5 48,603.6 16.6\n", + "28 ND 193,633.3 31,849.0 16.4\n", + "48 WI 1,360,253.0 216,446.1 15.9\n", + "45 VA 1,844,934.6 291,574.5 15.8\n", + "0 AK 183,148.1 28,983.4 15.8\n", + "19 MA 1,358,034.5 214,287.2 15.8\n", + "14 IL 2,708,379.5 427,662.1 15.8\n", + "31 NJ 1,897,915.1 274,861.4 14.5\n", + "39 RI 209,629.1 30,411.1 14.5\n", + "15 IN 1,694,145.8 241,712.4 14.3\n", + "46 VT 121,618.4 17,258.6 14.2\n", + "41 SD 211,732.2 29,992.9 14.2\n", + "26 MT 244,193.4 34,073.7 14.0\n", + "6 CT 688,378.7 96,338.9 14.0\n", + "50 WY 138,866.8 19,347.6 13.9\n", + "12 IA 807,211.3 102,575.1 12.7\n", + "20 MD 1,287,321.9 162,304.1 12.6\n", + "30 NH 268,315.1 32,842.4 12.2\n", + "37 OR 857,948.7 103,407.1 12.1\n", + "23 MN 1,286,774.4 155,286.9 12.1\n", + "47 WA 1,706,458.2 204,042.9 12.0\n", + "5 CO 1,192,968.0 139,685.5 11.7\n", + "13 ID 503,665.4 53,597.1 10.6\n", + "44 UT 943,210.6 95,065.9 10.1\n", + "29 NE 506,348.8 39,077.0 7.7\n" ] } ], "source": [ - "# Define states with exemptions\n", - "state_to_exemption = {\n", - " 'AL': ['al_personal_exemption'], 'CA': ['ca_exemptions'],\n", - " 'GA': ['ga_exemptions'], 'HI': ['hi_exemptions'],\n", - " 'IN': ['in_base_exemptions'], 'IL': ['il_dependent_exemption'],\n", - " 'KS': ['ks_exemptions'], 'LA': ['la_dependents_exemption'],\n", - " 'MD': ['md_total_personal_exemptions'], 'MI': ['mi_exemptions'],\n", - " 'MN': ['mn_exemptions'], 'MS': ['ms_dependents_exemption'],\n", - " 'MT': ['mt_dependent_exemptions_person'], 'MA': ['ma_income_tax_exemption_threshold'],\n", - " 'NC': ['nc_child_deduction'], 'NM': ['nm_deduction_for_certain_dependents'],\n", - " 'NE': ['ne_exemptions'], 'NJ': ['nj_dependents_exemption'],\n", - " 'NY': ['ny_exemptions'], 'OH': ['oh_personal_exemptions'],\n", - " 'OK': ['ok_exemptions'], 'RI': ['ri_exemptions'],\n", - " 'SC': ['sc_dependent_exemption'], 'UT': ['ut_exemptions'],\n", - " 'VA': ['va_personal_exemption'],\n", - " 'VT': ['vt_personal_exemptions'], 'WI': ['wi_exemptions'],\n", - " 'WV': ['wv_personal_exemption']\n", - "}\n", - "\n", "# Get required variables\n", - "state_codes = baseline.calculate(\"state_code\", period=2024)\n", - "num_children = baseline.calculate(\"tax_unit_children\", map_to='household', period=2024)\n", + "state_codes = baseline.calculate(\"state_code\", period=2025)\n", + "num_children = baseline.calculate(\"tax_unit_children\", map_to='household', period=2025)\n", "baseline_tax = baseline.calculate(\"state_income_tax_before_refundable_credits\", map_to='household', period=2024)\n", "reformed_tax = reformed.calculate(\"state_income_tax_before_refundable_credits\", map_to='household', period=2024)\n", "\n", @@ -311,10 +314,6 @@ " 'zero_tax_both': (np.abs(baseline_tax) < 0.01) & (np.abs(reformed_tax) < 0.01)\n", "})\n", "\n", - "# Filter for states we want to analyze (exemption states + TX for verification)\n", - "states_to_show = list(state_to_exemption.keys()) + ['TX']\n", - "results = results[results['state_code'].isin(states_to_show)]\n", - "\n", "# Get household weights\n", "weights = baseline.calculate(\"household_weight\", period=2024)\n", "\n", @@ -348,6 +347,13 @@ "print(state_results.to_string(float_format=lambda x: f\"{x:,.1f}\"))\n", "\n" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/us/state_dependent_exemptions/state_impacts_detailed.csv b/us/state_dependent_exemptions/state_impacts_detailed.csv index 9584023..5e949e4 100644 --- a/us/state_dependent_exemptions/state_impacts_detailed.csv +++ b/us/state_dependent_exemptions/state_impacts_detailed.csv @@ -1,53 +1,53 @@ state_code,income_change,total_households,total_state_income_impact,households_affected,percent_households_affected,avg_income_change_per_household -CA,-161.65538,14365824.0,-2322.313,,,-161.66000366210938 -MI,-113.0947,4228719.0,-478.246,,,-113.08999633789062 -GA,-94.5704,4348380.0,-411.228,,,-94.56999969482422 -MN,-166.80835,2344873.0,-391.144,,,-166.80999755859375 -IL,-61.881397,5187204.0,-320.991,,,-61.880001068115234 -NY,-28.510836,7896529.0,-225.137,,,-28.510000228881836 -SC,-100.73903,2221951.0,-223.837,,,-100.73999786376953 -NJ,-44.170063,3578201.0,-158.049,,,-44.16999816894531 -MD,-55.2758,2319566.0,-128.216,,,-55.279998779296875 -OH,-23.681173,4992720.0,-118.233,,,-23.68000030517578 -NC,-20.287275,4553814.0,-92.384,,,-20.290000915527344 -VA,-26.05071,3492310.0,-90.977,,,-26.049999237060547 -NE,-97.881355,799766.0,-78.282,,,-97.87999725341797 -UT,-63.841988,1150286.0,-73.437,,,-63.84000015258789 -IN,-18.07464,2804274.0,-50.686,,,-18.06999969482422 -WI,-17.732164,2559938.0,-45.393,,,-17.729999542236328 -MT,-86.0032,494750.0,-42.55,,,-86.0 -OK,-23.273746,1626192.0,-37.848,,,-23.270000457763672 -RI,-79.50533,463160.0,-36.824,,,-79.51000213623047 -MS,-29.100868,1201572.0,-34.967,,,-29.100000381469727 -VT,-107.14814,292460.0,-31.337,,,-107.1500015258789 -IA,-22.862263,1364209.0,-31.189,,,-22.860000610351562 -WV,-39.842545,750805.0,-29.914,,,-39.84000015258789 -AL,-12.515711,2120076.0,-26.534,,,-12.520000457763672 -NM,-27.952093,882902.0,-24.679,,,-27.950000762939453 -HI,-46.590252,500921.0,-23.338,,,-46.59000015258789 -LA,-9.251335,1870034.0,-17.3,,,-9.25 -MA,-0.35598665,2817993.0,-1.003,,,-0.36000001430511475 -KS,-0.040942732,1215639.0,-0.05,,,-0.03999999910593033 -TX,0.0,11362365.0,0.0,,,0.0 -WA,0.0,3185000.0,0.0,,,0.0 -OR,0.0,1752219.0,0.0,,,0.0 -SD,0.0,385189.0,0.0,,,0.0 -TN,0.0,2986816.0,0.0,,,0.0 -PA,0.0,5365676.0,0.0,,,0.0 -AK,0.0,275571.0,0.0,,,0.0 -NH,0.0,591239.0,0.0,,,0.0 -ND,0.0,338181.0,0.0,,,0.0 -MO,0.0,2570655.0,0.0,,,0.0 -ME,0.0,608698.0,0.0,,,0.0 -KY,0.0,1886632.0,0.0,,,0.0 -ID,0.0,769370.0,0.0,,,0.0 -FL,0.0,9323535.0,0.0,,,0.0 -DE,0.0,410404.0,0.0,,,0.0 -DC,0.0,330109.0,0.0,,,0.0 -CT,0.0,1503523.0,0.0,,,0.0 -CO,0.0,2440251.0,0.0,,,0.0 -AZ,0.0,2941938.0,0.0,,,0.0 -AR,0.0,1279007.0,0.0,,,0.0 -NV,0.0,1265835.0,0.0,,,0.0 -WY,0.0,242744.0,0.0,,,0.0 -TOTAL,,134260030.0,-5546.086,,,-4.130854072789138e-05 +CA,-168.11597,14531141.0,-2442.917,,,-168.1199951171875 +MI,-113.27784,4277382.0,-484.533,,,-113.27999877929688 +GA,-94.607544,4398419.0,-416.124,,,-94.61000061035156 +MN,-172.84001,2371857.0,-409.952,,,-172.83999633789062 +IL,-61.743633,5246896.0,-323.962,,,-61.7400016784668 +NY,-28.856606,7987400.0,-230.489,,,-28.860000610351562 +SC,-101.62947,2247520.0,-228.414,,,-101.62999725341797 +NJ,-45.482822,3619377.0,-164.62,,,-45.47999954223633 +MD,-53.093952,2346259.0,-124.572,,,-53.09000015258789 +OH,-24.017212,5050174.0,-121.291,,,-24.020000457763672 +AZ,-35.651062,2975793.0,-106.09,,,-35.650001525878906 +VA,-26.366024,3532498.0,-93.138,,,-26.3700008392334 +NC,-18.682053,4606217.0,-86.054,,,-18.68000030517578 +UT,-70.31669,1163523.0,-81.815,,,-70.31999969482422 +ID,-105.1243,778224.0,-81.81,,,-105.12000274658203 +NE,-101.090546,808970.0,-81.779,,,-101.08999633789062 +ME,-130.30594,615702.0,-80.23,,,-130.30999755859375 +OK,-47.42907,1644905.0,-78.016,,,-47.43000030517578 +IN,-17.78423,2836545.0,-50.446,,,-17.780000686645508 +WI,-17.915783,2589397.0,-46.391,,,-17.920000076293945 +MT,-86.611115,500444.0,-43.344,,,-86.61000061035156 +RI,-82.698135,468489.0,-38.743,,,-82.69999694824219 +KY,-19.610373,1908343.0,-37.423,,,-19.610000610351562 +MS,-27.453508,1215399.0,-33.367,,,-27.450000762939453 +VT,-111.872406,295826.0,-33.095,,,-111.87000274658203 +IA,-22.93527,1379908.0,-31.649,,,-22.940000534057617 +WV,-40.327354,759445.0,-30.626,,,-40.33000183105469 +AL,-12.313282,2144474.0,-26.406,,,-12.3100004196167 +NM,-28.644913,893062.0,-25.582,,,-28.639999389648438 +DE,-51.414593,415126.0,-21.344,,,-51.40999984741211 +HI,-40.427452,506686.0,-20.484,,,-40.43000030517578 +AR,-12.242687,1293726.0,-15.839,,,-12.239999771118164 +MA,-0.348893,2850422.0,-0.994,,,-0.3499999940395355 +KS,-0.04094273,1229628.0,-0.05,,,-0.03999999910593033 +TX,0.0,11493119.0,0.0,,,0.0 +TN,0.0,3021187.0,0.0,,,0.0 +SD,0.0,389622.0,0.0,,,0.0 +WA,0.0,3221652.0,0.0,,,0.0 +AK,0.0,278742.0,0.0,,,0.0 +OR,0.0,1772383.0,0.0,,,0.0 +NV,0.0,1280402.0,0.0,,,0.0 +NH,0.0,598043.0,0.0,,,0.0 +ND,0.0,342073.0,0.0,,,0.0 +MO,0.0,2600237.0,0.0,,,0.0 +LA,0.0,1891554.0,0.0,,,0.0 +FL,0.0,9430827.0,0.0,,,0.0 +DC,0.0,333908.0,0.0,,,0.0 +CT,0.0,1520825.0,0.0,,,0.0 +CO,0.0,2468332.0,0.0,,,0.0 +PA,0.0,5427422.0,0.0,,,0.0 +WY,0.0,245537.0,0.0,,,0.0 +TOTAL,,135805040.0,-6091.589,,,-4.485539711928217e-05