From 2a2e893295867471b24c50a7d1f622dec1eb7936 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Wed, 19 Jun 2024 22:48:28 -0400 Subject: [PATCH] Black vs non-Black poverty rates under Wyden-Smith Fixes #2 --- us/black_poverty_trafwa.ipynb | 153 ++++++++++++++++++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 us/black_poverty_trafwa.ipynb diff --git a/us/black_poverty_trafwa.ipynb b/us/black_poverty_trafwa.ipynb new file mode 100644 index 0000000..40080fe --- /dev/null +++ b/us/black_poverty_trafwa.ipynb @@ -0,0 +1,153 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "from policyengine_us import Microsimulation\n", + "from policyengine_core.reforms import Reform\n", + "\n", + "reform = Reform.from_dict({\n", + " \"gov.contrib.congress.wyden_smith.actc_lookback\": {\n", + " \"2024-01-01.2025-12-31\": True\n", + " },\n", + " \"gov.contrib.congress.wyden_smith.per_child_actc_phase_in\": {\n", + " \"2023-01-01.2025-12-31\": True\n", + " },\n", + " \"gov.irs.credits.ctc.amount.base[0].amount\": {\n", + " \"2024-01-01.2025-12-31\": 2100\n", + " },\n", + " \"gov.irs.credits.ctc.refundable.individual_max\": {\n", + " \"2023-01-01.2023-12-31\": 1800,\n", + " \"2024-01-01.2024-12-31\": 1900,\n", + " \"2025-01-01.2025-12-31\": 2100\n", + " }\n", + "}, country_id=\"us\")\n", + "\n", + "\n", + "baseline = Microsimulation(dataset=\"enhanced_cps_2022\")\n", + "reformed = Microsimulation(reform=reform, dataset=\"enhanced_cps_2022\")" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False 0.180463\n", + "True 0.180111\n", + "dtype: float64" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "black = baseline.calc(\"cps_race\", 2024) == 2\n", + "baseline_pov = baseline.calc(\"in_poverty\", 2024)\n", + "reformed_pov = reformed.calc(\"in_poverty\", 2024)\n", + "\n", + "baseline_pov.groupby(black).mean()" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False 0.179157\n", + "True 0.177839\n", + "dtype: float64" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "reformed_pov.groupby(black).mean()" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "BLACK 0.178283\n", + "HISPANIC 0.173251\n", + "OTHER 0.187104\n", + "WHITE 0.181633\n", + "dtype: float64" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "race = baseline.calc(\"race\", 2024)\n", + "baseline_pov.groupby(race).mean()" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'0.792.0'" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import pkg_resources\n", + "\n", + "pkg_resources.get_distribution(\n", + " \"policyengine_us\"\n", + ").version" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "policyengine", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.16" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}