Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove data visualization functionality #229

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions docs/agg.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@
"metadata": {},
"outputs": [],
"source": [
"base = mdf.calc_df(group_vars=['expanded_income', 'MARS', 'XTOT'],\n",
" metric_vars='aftertax_income')"
"base = mdf.calc_df(\n",
" group_vars=[\"expanded_income\", \"MARS\", \"XTOT\"],\n",
" metric_vars=\"aftertax_income\",\n",
")"
]
},
{
Expand All @@ -71,9 +73,9 @@
"source": [
"reform = base.copy(deep=True)\n",
"UBI_PP = 10000\n",
"reform['ubi'] = reform.XTOT * UBI_PP\n",
"reform['aftertax_income'] = reform.aftertax_income + reform.ubi\n",
"mdf.add_weighted_metrics(reform, 'aftertax_income')"
"reform[\"ubi\"] = reform.XTOT * UBI_PP\n",
"reform[\"aftertax_income\"] = reform.aftertax_income + reform.ubi\n",
"mdf.add_weighted_metrics(reform, \"aftertax_income\")"
]
},
{
Expand Down Expand Up @@ -159,7 +161,7 @@
}
],
"source": [
"mdf.agg(base, reform, 'MARS', 'aftertax_income')"
"mdf.agg(base, reform, \"MARS\", \"aftertax_income\")"
]
},
{
Expand Down Expand Up @@ -254,7 +256,7 @@
}
],
"source": [
"mdf.agg(base, reform, 'MARS', 'aftertax_income', 'expanded_income')"
"mdf.agg(base, reform, \"MARS\", \"aftertax_income\", \"expanded_income\")"
]
},
{
Expand Down Expand Up @@ -349,9 +351,9 @@
}
],
"source": [
"mdf.add_weighted_metrics(reform, 'ubi') # Creates ubi_m = ubi * s006 / 1e6.\n",
"mdf.add_weighted_metrics(reform, \"ubi\") # Creates ubi_m = ubi * s006 / 1e6.\n",
"\n",
"mdf.agg(base, reform, 'MARS', 'aftertax_income', reform_metrics='ubi_m')"
"mdf.agg(base, reform, \"MARS\", \"aftertax_income\", reform_metrics=\"ubi_m\")"
]
}
],
Expand Down
263 changes: 0 additions & 263 deletions docs/charts.ipynb

This file was deleted.

22 changes: 12 additions & 10 deletions docs/custom_taxes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@
"metadata": {},
"outputs": [],
"source": [
"df = mdf.calc_df(group_vars=['expanded_income', 'aftertax_income'] +\n",
" mdf.ECI_REMOVE_COLS,\n",
" metric_vars=['XTOT'])\n",
"df = mdf.calc_df(\n",
" group_vars=[\"expanded_income\", \"aftertax_income\"] + mdf.ECI_REMOVE_COLS,\n",
" metric_vars=[\"XTOT\"],\n",
")\n",
"df.columns"
]
},
Expand All @@ -77,7 +78,7 @@
"metadata": {},
"outputs": [],
"source": [
"df['tpc_eci'] = mdf.tpc_eci(df)"
"df[\"tpc_eci\"] = mdf.tpc_eci(df)"
]
},
{
Expand Down Expand Up @@ -155,7 +156,7 @@
"metadata": {},
"outputs": [],
"source": [
"mdf.add_vat(df, total=500e9, name='vat2')\n",
"mdf.add_vat(df, total=500e9, name=\"vat2\")\n",
"df.columns"
]
},
Expand All @@ -165,7 +166,7 @@
"metadata": {},
"outputs": [],
"source": [
"mdf.weighted_sum(df, 'vat', 's006') / 1e9"
"mdf.weighted_sum(df, \"vat\", \"s006\") / 1e9"
]
},
{
Expand All @@ -174,7 +175,7 @@
"metadata": {},
"outputs": [],
"source": [
"mdf.weighted_sum(df, 'vat2', 's006') / 1e9"
"mdf.weighted_sum(df, \"vat2\", \"s006\") / 1e9"
]
},
{
Expand All @@ -190,8 +191,9 @@
"metadata": {},
"outputs": [],
"source": [
"mdf.add_custom_tax(df, 'tpc_eci', 'XTOT_m', 'aftertax_income', \n",
" mdf.VAT_INCIDENCE, 'vat3', 1e12)"
"mdf.add_custom_tax(\n",
" df, \"tpc_eci\", \"XTOT_m\", \"aftertax_income\", mdf.VAT_INCIDENCE, \"vat3\", 1e12\n",
")"
]
},
{
Expand All @@ -200,7 +202,7 @@
"metadata": {},
"outputs": [],
"source": [
"mdf.weighted_sum(df, 'vat3', 's006') / 1e9"
"mdf.weighted_sum(df, \"vat3\", \"s006\") / 1e9"
]
}
],
Expand Down
77 changes: 25 additions & 52 deletions docs/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,7 @@
"import pandas as pd\n",
"\n",
"import taxcalc as tc\n",
"import microdf as mdf\n",
"\n",
"import matplotlib as mpl\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Chart options."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/mghenis/anaconda3/lib/python3.7/site-packages/microdf/style.py:24: MatplotlibDeprecationWarning: \n",
"The createFontList function was deprecated in Matplotlib 3.2 and will be removed two minor releases later. Use FontManager.addfont instead.\n",
" fm.fontManager.ttflist += fm.createFontList([\"Roboto-Regular.ttf\"])\n"
]
}
],
"source": [
"mdf.set_plot_style()"
"import microdf as mdf"
]
},
{
Expand All @@ -70,8 +40,10 @@
"metadata": {},
"outputs": [],
"source": [
"base = mdf.calc_df(group_vars=['expanded_income', 'MARS'],\n",
" metric_vars=['aftertax_income', 'XTOT'])"
"base = mdf.calc_df(\n",
" group_vars=[\"expanded_income\", \"MARS\"],\n",
" metric_vars=[\"aftertax_income\", \"XTOT\"],\n",
")"
]
},
{
Expand Down Expand Up @@ -111,10 +83,7 @@
"metadata": {},
"outputs": [],
"source": [
"CG_REFORM = {\n",
" 'CG_nodiff': {2019: True},\n",
" 'II_rt7': {2019: 0.7}\n",
"}"
"CG_REFORM = {\"CG_nodiff\": {2019: True}, \"II_rt7\": {2019: 0.7}}"
]
},
{
Expand All @@ -123,8 +92,12 @@
"metadata": {},
"outputs": [],
"source": [
"reform = mdf.calc_df(reform=CG_REFORM, group_vars=['MARS'], group_n65=True, \n",
" metric_vars=['aftertax_income', 'XTOT'])"
"reform = mdf.calc_df(\n",
" reform=CG_REFORM,\n",
" group_vars=[\"MARS\"],\n",
" group_n65=True,\n",
" metric_vars=[\"aftertax_income\", \"XTOT\"],\n",
")"
]
},
{
Expand Down Expand Up @@ -206,7 +179,7 @@
}
],
"source": [
"mdf.add_weighted_metrics(reform, 'n65')\n",
"mdf.add_weighted_metrics(reform, \"n65\")\n",
"\n",
"n65_total_m = reform.n65_m.sum()\n",
"n65_total_m"
Expand Down Expand Up @@ -253,9 +226,9 @@
"metadata": {},
"outputs": [],
"source": [
"reform['ubi'] = senior_ubi * reform.n65\n",
"reform['aftertax_income'] = reform.aftertax_income + reform.ubi\n",
"mdf.add_weighted_metrics(reform, 'aftertax_income')"
"reform[\"ubi\"] = senior_ubi * reform.n65\n",
"reform[\"aftertax_income\"] = reform.aftertax_income + reform.ubi\n",
"mdf.add_weighted_metrics(reform, \"aftertax_income\")"
]
},
{
Expand Down Expand Up @@ -306,7 +279,7 @@
}
],
"source": [
"mdf.gini(base, 'aftertax_income', 's006')"
"mdf.gini(base, \"aftertax_income\", \"s006\")"
]
},
{
Expand All @@ -326,7 +299,7 @@
}
],
"source": [
"mdf.gini(reform, 'aftertax_income', 's006')"
"mdf.gini(reform, \"aftertax_income\", \"s006\")"
]
},
{
Expand All @@ -344,13 +317,13 @@
"metadata": {},
"outputs": [],
"source": [
"base['fpl'] = mdf.fpl(base.XTOT)\n",
"reform['fpl'] = mdf.fpl(reform.XTOT)\n",
"base[\"fpl\"] = mdf.fpl(base.XTOT)\n",
"reform[\"fpl\"] = mdf.fpl(reform.XTOT)\n",
"\n",
"base['fpl_XTOT_m'] = np.where(base.aftertax_income < base.fpl,\n",
" base.XTOT_m, 0)\n",
"reform['fpl_XTOT_m'] = np.where(reform.aftertax_income < reform.fpl,\n",
" reform.XTOT_m, 0)"
"base[\"fpl_XTOT_m\"] = np.where(base.aftertax_income < base.fpl, base.XTOT_m, 0)\n",
"reform[\"fpl_XTOT_m\"] = np.where(\n",
" reform.aftertax_income < reform.fpl, reform.XTOT_m, 0\n",
")"
]
},
{
Expand Down Expand Up @@ -408,4 +381,4 @@
},
"nbformat": 4,
"nbformat_minor": 2
}
}
26 changes: 13 additions & 13 deletions docs/gini.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"source": [
"x = [-10, -1, 0, 5, 100]\n",
"w = [1, 2, 3, 4, 5]\n",
"df = pd.DataFrame({'x': x, 'w': w})"
"df = pd.DataFrame({\"x\": x, \"w\": w})"
]
},
{
Expand All @@ -53,7 +53,7 @@
}
],
"source": [
"mdf.gini(df, 'x')"
"mdf.gini(df, \"x\")"
]
},
{
Expand Down Expand Up @@ -87,7 +87,7 @@
}
],
"source": [
"mdf.gini(df, 'x', negatives='zero')"
"mdf.gini(df, \"x\", negatives=\"zero\")"
]
},
{
Expand All @@ -107,7 +107,7 @@
}
],
"source": [
"mdf.gini(pd.DataFrame({'x': [0, 0, 0, 5, 100]}), 'x')"
"mdf.gini(pd.DataFrame({\"x\": [0, 0, 0, 5, 100]}), \"x\")"
]
},
{
Expand All @@ -134,7 +134,7 @@
}
],
"source": [
"mdf.gini(df, 'x', negatives='shift')"
"mdf.gini(df, \"x\", negatives=\"shift\")"
]
},
{
Expand All @@ -154,7 +154,7 @@
}
],
"source": [
"mdf.gini(pd.DataFrame({'x': [0, 9, 10, 15, 110]}), 'x')"
"mdf.gini(pd.DataFrame({\"x\": [0, 9, 10, 15, 110]}), \"x\")"
]
},
{
Expand All @@ -181,7 +181,7 @@
}
],
"source": [
"mdf.gini(df, 'x', 'w')"
"mdf.gini(df, \"x\", \"w\")"
]
},
{
Expand All @@ -201,12 +201,12 @@
}
],
"source": [
"mdf.gini(pd.DataFrame({'x': [-10,\n",
" -1, -1,\n",
" 0, 0, 0,\n",
" 5, 5, 5, 5,\n",
" 100, 100, 100, 100, 100]}),\n",
" 'x')"
"mdf.gini(\n",
" pd.DataFrame(\n",
" {\"x\": [-10, -1, -1, 0, 0, 0, 5, 5, 5, 5, 100, 100, 100, 100, 100]}\n",
" ),\n",
" \"x\",\n",
")"
]
}
],
Expand Down
16 changes: 12 additions & 4 deletions docs/income_measures.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,17 @@
"metadata": {},
"outputs": [],
"source": [
"df = mdf.calc_df(group_vars=['expanded_income', 'wic_ben', 'housing_ben', \n",
" 'vet_ben', 'mcare_ben', 'mcaid_ben'],\n",
" metric_vars=['XTOT'])"
"df = mdf.calc_df(\n",
" group_vars=[\n",
" \"expanded_income\",\n",
" \"wic_ben\",\n",
" \"housing_ben\",\n",
" \"vet_ben\",\n",
" \"mcare_ben\",\n",
" \"mcaid_ben\",\n",
" ],\n",
" metric_vars=[\"XTOT\"],\n",
")"
]
},
{
Expand All @@ -75,7 +83,7 @@
"metadata": {},
"outputs": [],
"source": [
"df['tpc_eci'] = mdf.tpc_eci(df)"
"df[\"tpc_eci\"] = mdf.tpc_eci(df)"
]
},
{
Expand Down
Loading