{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "# !pip install git+https://github.com/compute-tooling/compute-studio-kit.git@filespec\n", "!conda install taxcalc -c pslmodels -y" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import json\n", "\n", "import fsspec\n", "\n", "from cs_kit.filespec import CSFileSystem" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'II_rt1': [{'year': 2019, 'value': 0.25}],\n", " 'II_rt2': [{'year': 2019, 'value': 0.25}],\n", " 'II_rt3': [{'year': 2019, 'value': 0.25}],\n", " 'II_rt4': [{'year': 2019, 'value': 0.25}],\n", " 'II_rt5': [{'year': 2019, 'value': 0.25}],\n", " 'II_rt6': [{'year': 2019, 'value': 0.25}],\n", " 'II_rt7': [{'year': 2019, 'value': 0.7}],\n", " 'II_brk6': [{'MARS': 'widow', 'year': 2019, 'value': 2000000},\n", " {'MARS': 'headhh', 'year': 2019, 'value': 2000000},\n", " {'MARS': 'mseparate', 'year': 2019, 'value': 2000000},\n", " {'MARS': 'mjoint', 'year': 2019, 'value': 2000000},\n", " {'MARS': 'single', 'year': 2019, 'value': 2000000}]}" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with fsspec.open(\"cs://PSLmodels:Tax-Brain@47410/inputs/adjustment/policy/\", \"r\") as f:\n", " data = json.loads(f.read())\n", "data" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "OrderedDict([('II_rt1', [{'year': 2019, 'value': 0.25}]),\n", " ('II_rt2', [{'year': 2019, 'value': 0.25}]),\n", " ('II_rt3', [{'year': 2019, 'value': 0.25}]),\n", " ('II_rt4', [{'year': 2019, 'value': 0.25}]),\n", " ('II_rt5', [{'year': 2019, 'value': 0.25}]),\n", " ('II_rt6', [{'year': 2019, 'value': 0.25}]),\n", " ('II_brk6',\n", " [{'year': 2019, 'value': 2000000.0, 'MARS': 'widow'},\n", " {'year': 2019, 'value': 2000000.0, 'MARS': 'headhh'},\n", " {'year': 2019, 'value': 2000000.0, 'MARS': 'mseparate'},\n", " {'year': 2019, 'value': 2000000.0, 'MARS': 'mjoint'},\n", " {'year': 2019, 'value': 2000000.0, 'MARS': 'single'}]),\n", " ('II_rt7', [{'year': 2019, 'value': 0.7}])])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import taxcalc\n", "\n", "pol = taxcalc.Policy()\n", "pol.adjust(\"cs://PSLmodels:Tax-Brain@47410/inputs/adjustment/policy\")" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "import io\n", "\n", "import pandas as pd\n", "import paramtools\n", "\n", "data = paramtools.read_json(\"cs://PSLmodels:Tax-Brain@47410/outputs\")\n", "\n", "results = []\n", "for output in data:\n", " results.append(\n", " pd.read_csv(io.StringIO(output[\"data\"]))\n", " )" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 020192020202120222023202420252026202720282029
0Individual Income Tax Liability Change$651.31$677.74$707.50$735.71$764.94$793.97$824.71$609.33$631.98$654.94$678.08
1Payroll Tax Liability Change$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00$0.00
2Combined Payroll and Individual Income Tax Lia...$651.31$677.74$707.50$735.71$764.94$793.97$824.71$609.33$631.98$654.94$678.08
\n", "
" ], "text/plain": [ " Unnamed: 0 2019 2020 \\\n", "0 Individual Income Tax Liability Change $651.31 $677.74 \n", "1 Payroll Tax Liability Change $0.00 $0.00 \n", "2 Combined Payroll and Individual Income Tax Lia... $651.31 $677.74 \n", "\n", " 2021 2022 2023 2024 2025 2026 2027 2028 \\\n", "0 $707.50 $735.71 $764.94 $793.97 $824.71 $609.33 $631.98 $654.94 \n", "1 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 $0.00 \n", "2 $707.50 $735.71 $764.94 $793.97 $824.71 $609.33 $631.98 $654.94 \n", "\n", " 2029 \n", "0 $678.08 \n", "1 $0.00 \n", "2 $678.08 " ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results[0]" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'owner': 'MaxGhenis'}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with fsspec.open(\"cs://PSLmodels:Tax-Brain@47410/owner\") as f:\n", " result = json.loads(f.read())\n", "\n", "result" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'title': 'Super secret sim'}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "with fsspec.open(\"cs://PSLmodels:Tax-Cruncher@520/title\", api_token=\"your-api-token\") as f:\n", " result = json.loads(f.read())\n", "result" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.3" } }, "nbformat": 4, "nbformat_minor": 4 }