{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "from ydata_profiling import ProfileReport\n", "\n", "df = pd.DataFrame(np.random.rand(100, 5), columns=[\"a\", \"b\", \"c\", \"d\", \"e\"])" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "profile = ProfileReport(df, title=\"Profiling Report\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Summarize dataset: 100%|██████████| 39/39 [00:01<00:00, 27.26it/s, Completed] \n", "Generate report structure: 100%|██████████| 1/1 [00:00<00:00, 1.40it/s]\n", "Render HTML: 100%|██████████| 1/1 [00:00<00:00, 4.06it/s]\n" ] }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "profile" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Export report to file: 100%|██████████| 1/1 [00:00<00:00, 525.40it/s]\n" ] } ], "source": [ "profile.to_file(\"eda_pandas.html\")" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "def calculate_tax_comparison(income, mortgage_interest, property_tax, \n", " charitable_donations, state_local_tax,\n", " child_tax_credit=2000):\n", " \"\"\"\n", " Calculate and compare taxes using standard vs itemized deductions\n", " for married filing jointly with one child\n", " \n", " Parameters:\n", " income: Annual household income\n", " mortgage_interest: Annual mortgage interest paid\n", " property_tax: Annual property tax paid\n", " charitable_donations: Annual charitable contributions\n", " state_local_tax: State and local taxes paid\n", " child_tax_credit: Child tax credit amount (default $2000)\n", " \"\"\"\n", " # 2024 tax brackets for married filing jointly\n", " tax_brackets = [\n", " (0, 22000, 0.10),\n", " (22000, 89450, 0.12),\n", " (89450, 190750, 0.22),\n", " (190750, 364200, 0.24),\n", " (364200, 462500, 0.32),\n", " (462500, 693750, 0.35),\n", " (693750, float('inf'), 0.37)\n", " ]\n", " \n", " # 2024 standard deduction for married filing jointly\n", " standard_deduction = 27700\n", " \n", " # Calculate itemized deductions\n", " salt_cap = 10000 # State and Local Tax deduction cap\n", " total_salt = min(state_local_tax + property_tax, salt_cap)\n", " \n", " itemized_deductions = (mortgage_interest + \n", " total_salt + \n", " charitable_donations)\n", " \n", " def calculate_tax(taxable_income):\n", " tax = 0\n", " for lower, upper, rate in tax_brackets:\n", " if taxable_income > lower:\n", " taxable_in_bracket = min(taxable_income - lower, upper - lower)\n", " tax += taxable_in_bracket * rate\n", " return tax\n", " \n", " # Calculate taxes both ways\n", " standard_taxable_income = max(income - standard_deduction, 0)\n", " itemized_taxable_income = max(income - itemized_deductions, 0)\n", " \n", " standard_tax = calculate_tax(standard_taxable_income)\n", " itemized_tax = calculate_tax(itemized_taxable_income)\n", " \n", " # Apply child tax credit\n", " standard_tax = max(standard_tax - child_tax_credit, 0)\n", " itemized_tax = max(itemized_tax - child_tax_credit, 0)\n", " \n", " return {\n", " 'Standard Deduction': {\n", " 'Deduction Amount': standard_deduction,\n", " 'Taxable Income': standard_taxable_income,\n", " 'Tax Before Credits': calculate_tax(standard_taxable_income),\n", " 'Final Tax': standard_tax\n", " },\n", " 'Itemized Deduction': {\n", " 'Total Deductions': itemized_deductions,\n", " 'Deduction Breakdown': {\n", " 'Mortgage Interest': mortgage_interest,\n", " 'SALT (capped)': total_salt,\n", " 'Charitable Donations': charitable_donations\n", " },\n", " 'Taxable Income': itemized_taxable_income,\n", " 'Tax Before Credits': calculate_tax(itemized_taxable_income),\n", " 'Final Tax': itemized_tax\n", " },\n", " 'Difference': abs(standard_tax - itemized_tax),\n", " 'Better Option': 'Standard Deduction' if standard_tax <= itemized_tax else 'Itemized Deduction'\n", " }" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'Standard Deduction': {'Deduction Amount': 27700,\n", " 'Taxable Income': 222300,\n", " 'Tax Before Credits': 40152.0,\n", " 'Final Tax': 38152.0},\n", " 'Itemized Deduction': {'Total Deductions': 38955,\n", " 'Deduction Breakdown': {'Mortgage Interest': 38000,\n", " 'SALT (capped)': 455,\n", " 'Charitable Donations': 500},\n", " 'Taxable Income': 211045,\n", " 'Tax Before Credits': 37450.8,\n", " 'Final Tax': 35450.8},\n", " 'Difference': 2701.199999999997,\n", " 'Better Option': 'Itemized Deduction'}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "calculate_tax_comparison(250000, 38000, 450, 500, 5, 2000)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "36000" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "3000 * 12" ] } ], "metadata": { "kernelspec": { "display_name": "pytorch_m1", "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.13" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }