From 0f12cd863a35b7e58593327be0a6c7532a8f9b83 Mon Sep 17 00:00:00 2001 From: xiwang Date: Thu, 17 Aug 2023 11:31:08 -0400 Subject: [PATCH 1/4] Add new docs --- docs/book/_toc.yml | 1 + .../gov/hmrc/national-insurance.ipynb | 6009 +++++++++++++++++ 2 files changed, 6010 insertions(+) create mode 100644 docs/book/programs/gov/hmrc/national-insurance.ipynb diff --git a/docs/book/_toc.yml b/docs/book/_toc.yml index 43d2da370..57f582d04 100644 --- a/docs/book/_toc.yml +++ b/docs/book/_toc.yml @@ -9,6 +9,7 @@ parts: - caption: Programs chapters: - file: programs/gov/hmrc/child-benefit + - file: programs/gov/hmrc/national-insurance - file: programs/contrib/ubi-center/carbon-tax - file: programs/gov/ofgem/energy-price-guarantee - caption: Using the model diff --git a/docs/book/programs/gov/hmrc/national-insurance.ipynb b/docs/book/programs/gov/hmrc/national-insurance.ipynb new file mode 100644 index 000000000..635da4531 --- /dev/null +++ b/docs/book/programs/gov/hmrc/national-insurance.ipynb @@ -0,0 +1,6009 @@ +{ + "cells": [ + { + "attachments": {}, + "cell_type": "markdown", + "metadata": { + "id": "_gdKAFopTwuB" + }, + "source": [ + "# National Insurance" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "b3G5DBwhos_2" + }, + "source": [ + "National Insurance is a key component of the UK tax system. It primarily funds certain types of welfare and state benefits, including the State Pension. Here's an overview of National Insurance:\n", + "\n", + "**Purpose**:\\\n", + "The main purpose of National Insurance is to fund various state benefits such as the State Pension, unemployment benefits, maternity allowance, and sickness and disability allowances.\n", + "\n", + "**Types of National Insurance Contributions (NICs):**\\\n", + "**Class 1**: Paid by employees and their employers. This is based on the employee's earnings and is deducted directly from wages.\\\n", + "**Class 2**: Paid by self-employed people with profits above a certain threshold.\\\n", + "**Class 3**: Voluntary contributions, often made by people who want to fill gaps in their National Insurance record.\\\n", + "**Class 4**: Paid by self-employed people with profits above a certain threshold, in addition to Class 2 NICs." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ie5U-X3ruXj3" + }, + "source": [ + "# Methodology\n", + "\n", + "The table outlines the methodology used by PolicyEngine UK to model Class 1, 2, and 4 National Insurance:" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "cellView": "form", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "SfKRQHzBm1rQ", + "outputId": "ca2e1cc7-616a-433c-c1e3-6a0e95f48fbc" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "+---------+------------------------------------------------------------------+---------------------------+-----------------------------+----------------------------------------------------------+\n", + "| Class | Methodology & Basis | Thresholds & Limits | Rate Application | Reference |\n", + "+=========+==================================================================+===========================+=============================+==========================================================+\n", + "| Class 1 | - Based on employment income. | - Primary Threshold | - Main and Additional rates | Social Security Contributions and Benefits Act 1992 s. 8 |\n", + "| | - Monthly and annual calculations. | - Upper Earnings Limit | | |\n", + "+---------+------------------------------------------------------------------+---------------------------+-----------------------------+----------------------------------------------------------+\n", + "| Class 2 | - Based on self-employment income. | - Small Profits Threshold | - Flat rate | Social Security and Benefits Act 1992 s. 11 |\n", + "| | - Weekly flat rate. | | | |\n", + "+---------+------------------------------------------------------------------+---------------------------+-----------------------------+----------------------------------------------------------+\n", + "| Class 4 | - Derived from self-employment income minus Class 1 employee NI. | - Lower Profits Limit | - Main and Additional rates | Social Security and Benefits Act 1992 s. 15 |\n", + "| | | - Upper Profits Limit | | |\n", + "+---------+------------------------------------------------------------------+---------------------------+-----------------------------+----------------------------------------------------------+\n" + ] + } + ], + "source": [ + "# @title\n", + "import pandas as pd\n", + "from tabulate import tabulate\n", + "\n", + "\n", + "data = {\n", + " \"Class\": [\"Class 1\", \"Class 2\", \"Class 4\"],\n", + " \"Methodology & Basis\": [\n", + " \"- Based on employment income. \\n- Monthly and annual calculations.\",\n", + " \"- Based on self-employment income. \\n- Weekly flat rate.\",\n", + " \"- Derived from self-employment income minus Class 1 employee NI.\"\n", + " ],\n", + " \"Thresholds & Limits\": [\n", + " \"- Primary Threshold \\n- Upper Earnings Limit\",\n", + " \"- Small Profits Threshold\",\n", + " \"- Lower Profits Limit \\n- Upper Profits Limit\"\n", + " ],\n", + " \"Rate Application\": [\n", + " \"- Main and Additional rates\",\n", + " \"- Flat rate\",\n", + " \"- Main and Additional rates\"\n", + " ],\n", + " \"Reference\": [\n", + " \"Social Security Contributions and Benefits Act 1992 s. 8\",\n", + " \"Social Security and Benefits Act 1992 s. 11\",\n", + " \"Social Security and Benefits Act 1992 s. 15\"\n", + " ]\n", + "}\n", + "\n", + "df = pd.DataFrame(data)\n", + "\n", + "# Print the table without the index column\n", + "print(tabulate(df, headers='keys', tablefmt='grid', showindex=False))\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "bxQD7vfe1t2n" + }, + "source": [ + "# Appendix:\n", + "**- Class 1 National Insurance Rates:**" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "cellView": "form", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 542 + }, + "id": "4XPp9G3Q4tbi", + "outputId": "1e4c9c0a-8f03-49ba-dcc0-d1f0ae9cbe45" + }, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "alignmentgroup": "True", + "hovertemplate": "Type=NI Class 1 Main Rate
Date=%{x}
Rates=%{y}", + "legendgroup": "NI Class 1 Main Rate", + "marker": { + "color": "#636efa", + "pattern": { + "shape": "" + } + }, + "name": "NI Class 1 Main Rate", + "offsetgroup": "NI Class 1 Main Rate", + "orientation": "v", + "showlegend": true, + "textposition": "auto", + "type": "bar", + "x": [ + "2015-06-01", + "2022-04-01", + "2022-11-06" + ], + "xaxis": "x", + "y": [ + 0.12, + 0.1325, + 0.12 + ], + "yaxis": "y" + }, + { + "alignmentgroup": "True", + "hovertemplate": "Type=NI Class 1 Additional Rate
Date=%{x}
Rates=%{y}", + "legendgroup": "NI Class 1 Additional Rate", + "marker": { + "color": "#EF553B", + "pattern": { + "shape": "" + } + }, + "name": "NI Class 1 Additional Rate", + "offsetgroup": "NI Class 1 Additional Rate", + "orientation": "v", + "showlegend": true, + "textposition": "auto", + "type": "bar", + "x": [ + "2015-06-01", + "2022-04-01" + ], + "xaxis": "x", + "y": [ + 0.02, + 0.0325 + ], + "yaxis": "y" + }, + { + "alignmentgroup": "True", + "hovertemplate": "Type=NI Employer Rate
Date=%{x}
Rates=%{y}", + "legendgroup": "NI Employer Rate", + "marker": { + "color": "#00cc96", + "pattern": { + "shape": "" + } + }, + "name": "NI Employer Rate", + "offsetgroup": "NI Employer Rate", + "orientation": "v", + "showlegend": true, + "textposition": "auto", + "type": "bar", + "x": [ + "2015-06-01" + ], + "xaxis": "x", + "y": [ + 0.138 + ], + "yaxis": "y" + } + ], + "layout": { + "barmode": "relative", + "legend": { + "title": { + "text": "Type" + }, + "tracegroupgap": 0 + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Class 1 National Insurance Rates Over Time" + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Date" + } + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Rates" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# @title\n", + "import plotly.express as px\n", + "\n", + "dates_employee_additional = [\"2015-06-01\", \"2022-04-01\"]\n", + "rates_employee_additional = [0.02, 0.0325]\n", + "\n", + "dates_employee_main = [\"2015-06-01\", \"2022-04-01\", \"2022-11-06\"]\n", + "rates_employee_main = [0.12, 0.1325, 0.12]\n", + "\n", + "dates_employer = [\"2015-06-01\"]\n", + "rates_employer = [0.138]\n", + "\n", + "dates = sorted(set(dates_employee_additional + dates_employee_main + dates_employer))\n", + "df_employee_additional = pd.DataFrame({'Date': dates_employee_additional, 'Rate': rates_employee_additional, 'Type': 'NI Class 1 Additional Rate'})\n", + "df_employee_main = pd.DataFrame({'Date': dates_employee_main, 'Rate': rates_employee_main, 'Type': 'NI Class 1 Main Rate'})\n", + "df_employer = pd.DataFrame({'Date': dates_employer, 'Rate': rates_employer, 'Type': 'NI Employer Rate'})\n", + "\n", + "df = pd.concat([df_employee_main, df_employee_additional, df_employer], ignore_index=True)\n", + "\n", + "fig = px.bar(df, x='Date', y='Rate', color='Type',\n", + " title='Class 1 National Insurance Rates',\n", + " labels={'Date': 'Date', 'Rate': 'Rates'},\n", + " category_orders={\"Type\": [\"NI Class 1 Main Rate\", \"NI Class 1 Additional Rate\", \"NI Employer Rate\"]})\n", + "\n", + "fig.show()\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "sWgDc7c_2iVp" + }, + "source": [ + "**- Class 1 National Insurance Thresholds:**\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "cellView": "form", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 542 + }, + "id": "TMpoDSZP9Osd", + "outputId": "b771a3a2-14fe-4c66-8a9f-05c414f78954" + }, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "hovertemplate": "Thresholds=Lower Earnings Limit
Dates=%{x}
Thresholds (GBP)=%{y}", + "legendgroup": "Lower Earnings Limit", + "line": { + "color": "#636efa", + "dash": "solid" + }, + "marker": { + "symbol": "circle" + }, + "mode": "lines", + "name": "Lower Earnings Limit", + "orientation": "v", + "showlegend": true, + "type": "scatter", + "x": [ + "2015-04-06", + "2016-04-06", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", + "2022-04-06" + ], + "xaxis": "x", + "y": [ + 112, + 112, + 113, + 116, + 118, + 120, + 120, + 123 + ], + "yaxis": "y" + }, + { + "hovertemplate": "Thresholds=Primary Threshold
Dates=%{x}
Thresholds (GBP)=%{y}", + "legendgroup": "Primary Threshold", + "line": { + "color": "#EF553B", + "dash": "solid" + }, + "marker": { + "symbol": "circle" + }, + "mode": "lines", + "name": "Primary Threshold", + "orientation": "v", + "showlegend": true, + "type": "scatter", + "x": [ + "2015-04-06", + "2016-04-06", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", + "2022-04-06" + ], + "xaxis": "x", + "y": [ + 155, + 155, + 157, + 162, + 166, + 183, + 184, + 190 + ], + "yaxis": "y" + }, + { + "hovertemplate": "Thresholds=Secondary Threshold
Dates=%{x}
Thresholds (GBP)=%{y}", + "legendgroup": "Secondary Threshold", + "line": { + "color": "#00cc96", + "dash": "solid" + }, + "marker": { + "symbol": "circle" + }, + "mode": "lines", + "name": "Secondary Threshold", + "orientation": "v", + "showlegend": true, + "type": "scatter", + "x": [ + "2015-04-06", + "2016-04-06", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", + "2022-04-06" + ], + "xaxis": "x", + "y": [ + 155, + 155, + 157, + 162, + 166, + 169, + 170, + 175 + ], + "yaxis": "y" + }, + { + "hovertemplate": "Thresholds=Upper Earnings Limit
Dates=%{x}
Thresholds (GBP)=%{y}", + "legendgroup": "Upper Earnings Limit", + "line": { + "color": "#ab63fa", + "dash": "solid" + }, + "marker": { + "symbol": "circle" + }, + "mode": "lines", + "name": "Upper Earnings Limit", + "orientation": "v", + "showlegend": true, + "type": "scatter", + "x": [ + "2015-04-06", + "2016-04-06", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", + "2022-04-06" + ], + "xaxis": "x", + "y": [ + 815, + 827, + 866, + 892, + 962, + 962, + 966.73, + 966.73 + ], + "yaxis": "y" + } + ], + "layout": { + "legend": { + "title": { + "text": "Thresholds" + }, + "tracegroupgap": 0 + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Class 1 National Insurance Thresholds Over Time" + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Dates" + } + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Thresholds (GBP)" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# @title\n", + "dates = ['2015-04-06', '2016-04-06', '2017-04-06', '2018-04-06', '2019-04-06', '2020-04-06', '2021-04-06', '2022-04-06']\n", + "\n", + "lower_earnings = [112, 112, 113, 116, 118, 120, 120, 123]\n", + "primary_threshold = [155, 155, 157, 162, 166, 183, 184, 190]\n", + "secondary_threshold = [155, 155, 157, 162, 166, 169, 170, 175]\n", + "upper_earnings = [815, 827, 866, 892, 962, 962, 966.73, 966.73]\n", + "\n", + "df = pd.DataFrame({\n", + " 'Dates': dates,\n", + " 'Lower Earnings Limit': lower_earnings,\n", + " 'Primary Threshold': primary_threshold,\n", + " 'Secondary Threshold': secondary_threshold,\n", + " 'Upper Earnings Limit': upper_earnings\n", + "})\n", + "\n", + "fig = px.line(df, x='Dates', y=df.columns[1:],\n", + " title='Class 1 National Insurance Thresholds Over Time',\n", + " labels={'value': 'Thresholds (GBP)', 'variable': 'Thresholds', 'Dates': 'Dates'})\n", + "\n", + "fig.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ePYoUq0Y3XLb" + }, + "source": [ + "**- Class 2 National Insurance Rates:**" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "cellView": "form", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 542 + }, + "id": "2nnoLaMakEsZ", + "outputId": "e4fc445f-48b7-46eb-ce6e-4b9e14e36c18" + }, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "hovertemplate": "Dates=%{x}
Flat rate (GBP)=%{y}", + "legendgroup": "", + "line": { + "color": "blue", + "dash": "solid" + }, + "marker": { + "symbol": "circle" + }, + "mode": "lines+markers", + "name": "", + "orientation": "v", + "showlegend": false, + "type": "scatter", + "x": [ + "2015-06-01", + "2017-06-01", + "2018-06-01", + "2019-06-01", + "2020-06-01", + "2022-04-06" + ], + "xaxis": "x", + "y": [ + 2.8, + 2.85, + 2.95, + 3, + 3.05, + 3.15 + ], + "yaxis": "y" + } + ], + "layout": { + "legend": { + "tracegroupgap": 0 + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Class 2 National Insurance: Flat rate" + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Dates" + } + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Flat rate (GBP)" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# @title\n", + "\n", + "dates_flat_rate = ['2015-06-01', '2017-06-01', '2018-06-01', '2019-06-01', '2020-06-01', '2022-04-06']\n", + "flat_rate_values = [2.80, 2.85, 2.95, 3.00, 3.05, 3.15]\n", + "df_flat_rate = pd.DataFrame({'Dates': dates_flat_rate, 'Flat rate': flat_rate_values})\n", + "\n", + "dates_small_profits = ['2015-04-06', '2017-04-06', '2018-04-06', '2019-04-06', '2020-04-06', '2021-04-06', '2022-04-06']\n", + "small_profits_values = [3965, 6025, 6205, 6365, 6475, 6515, 6725]\n", + "df_small_profits = pd.DataFrame({'Dates': dates_small_profits, 'Small profits threshold': small_profits_values})\n", + "\n", + "fig_flat_rate = px.line(df_flat_rate, x='Dates', y='Flat rate',\n", + " title='Class 2 National Insurance: Flat rate',\n", + " labels={'Dates': 'Dates', 'Flat rate': 'Flat rate (GBP)'},\n", + " markers=True, color_discrete_sequence=['blue'])\n", + "fig_flat_rate.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "nu9MatvD34bc" + }, + "source": [ + "**- Class 2 National Insurance Thresholds**" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "cellView": "form", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 542 + }, + "id": "THpgsF7A309V", + "outputId": "4261ff0f-8da0-4b70-ef71-a32ede36a2e9" + }, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "hovertemplate": "Dates=%{x}
Small profits threshold (GBP)=%{y}", + "legendgroup": "", + "line": { + "color": "red", + "dash": "solid" + }, + "marker": { + "symbol": "circle" + }, + "mode": "lines+markers", + "name": "", + "orientation": "v", + "showlegend": false, + "type": "scatter", + "x": [ + "2015-04-06", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", + "2022-04-06" + ], + "xaxis": "x", + "y": [ + 3965, + 6025, + 6205, + 6365, + 6475, + 6515, + 6725 + ], + "yaxis": "y" + } + ], + "layout": { + "legend": { + "tracegroupgap": 0 + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Class 2 National Insurance: Small profits threshold" + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Dates" + } + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Small profits threshold (GBP)" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# @title\n", + "fig_small_profits = px.line(df_small_profits, x='Dates', y='Small profits threshold',\n", + " title='Class 2 National Insurance: Small profits threshold',\n", + " labels={'Dates': 'Dates', 'Small profits threshold': 'Small profits threshold (GBP)'},\n", + " markers=True, color_discrete_sequence=['red'])\n", + "fig_small_profits.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "WCMSiBiz4Dzq" + }, + "source": [ + "**- Class 4 National Insurance Rates:**" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "cellView": "form", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 542 + }, + "id": "IkPwua4Rmi-7", + "outputId": "1e254d6e-5971-4f22-8828-ddd9c13363fd" + }, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "alignmentgroup": "True", + "hovertemplate": "Rate Type=Class 4 Main Rate
Date=%{x}
Rates=%{y}", + "legendgroup": "Class 4 Main Rate", + "marker": { + "color": "#636efa", + "pattern": { + "shape": "" + } + }, + "name": "Class 4 Main Rate", + "offsetgroup": "Class 4 Main Rate", + "orientation": "v", + "showlegend": true, + "textposition": "auto", + "type": "bar", + "x": [ + "2015-06-01", + "2022-04-01", + "2022-11-06" + ], + "xaxis": "x", + "y": [ + 0.09, + 0.1025, + 0.09 + ], + "yaxis": "y" + }, + { + "alignmentgroup": "True", + "hovertemplate": "Rate Type=Class 4 Additional Rate
Date=%{x}
Rates=%{y}", + "legendgroup": "Class 4 Additional Rate", + "marker": { + "color": "#EF553B", + "pattern": { + "shape": "" + } + }, + "name": "Class 4 Additional Rate", + "offsetgroup": "Class 4 Additional Rate", + "orientation": "v", + "showlegend": true, + "textposition": "auto", + "type": "bar", + "x": [ + "2015-06-01", + "2022-04-01" + ], + "xaxis": "x", + "y": [ + 0.02, + 0.035 + ], + "yaxis": "y" + } + ], + "layout": { + "bargap": 0.8, + "barmode": "relative", + "legend": { + "title": { + "text": "Rate Type" + }, + "tracegroupgap": 0 + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Class 4 National Insurance Rates Over Time" + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Date" + }, + "type": "category" + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Rates" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# @title\n", + "\n", + "dates_main = [\"2015-06-01\", \"2022-04-01\", \"2022-11-06\"]\n", + "rates_main = [0.09, 0.1025, 0.09]\n", + "\n", + "dates_additional = [\"2015-06-01\", \"2022-04-01\"]\n", + "rates_additional = [0.02, 0.035]\n", + "\n", + "df_main = pd.DataFrame({\n", + " 'Date': dates_main,\n", + " 'Rate': rates_main,\n", + " 'Rate Type': 'Class 4 Main Rate'\n", + "})\n", + "\n", + "df_additional = pd.DataFrame({\n", + " 'Date': dates_additional,\n", + " 'Rate': rates_additional,\n", + " 'Rate Type': 'Class 4 Additional Rate'\n", + "})\n", + "\n", + "df = pd.concat([df_main, df_additional], ignore_index=True)\n", + "\n", + "fig = px.bar(df, x='Date', y='Rate', color='Rate Type',\n", + " title='Class 4 National Insurance Rates Over Time',\n", + " labels={'Date': 'Date', 'Rate': 'Rates'},\n", + " category_orders={\"Rate Type\": [\"Class 4 Main Rate\", \"Class 4 Additional Rate\"]})\n", + "\n", + "fig.update_layout(bargap=0.8)\n", + "fig.update_xaxes(type='category')\n", + "\n", + "fig.show()\n", + "\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "qFtjkiGq4JHW" + }, + "source": [ + "**- Class 4 National Insurance Thresholds:**" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "cellView": "form", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 542 + }, + "id": "SCRMpZI-osFV", + "outputId": "5d6a274e-0bf2-469d-e650-1a21cd0f2b93" + }, + "outputs": [ + { + "data": { + "application/vnd.plotly.v1+json": { + "config": { + "plotlyServerURL": "https://plot.ly" + }, + "data": [ + { + "hovertemplate": "Label=Lower Profits Limit
Dates=%{x}
Values=%{y}", + "legendgroup": "Lower Profits Limit", + "line": { + "color": "#636efa", + "dash": "solid" + }, + "marker": { + "symbol": "circle" + }, + "mode": "lines+markers", + "name": "Lower Profits Limit", + "orientation": "v", + "showlegend": true, + "type": "scatter", + "x": [ + "2015-04-06", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", + "2022-04-06", + "2026-04-06" + ], + "xaxis": "x", + "y": [ + 8060, + 8164, + 8424, + 8632, + 9500, + 9568, + 11908, + 12570 + ], + "yaxis": "y" + }, + { + "hovertemplate": "Label=Upper Profits Limit
Dates=%{x}
Values=%{y}", + "legendgroup": "Upper Profits Limit", + "line": { + "color": "#EF553B", + "dash": "solid" + }, + "marker": { + "symbol": "circle" + }, + "mode": "lines+markers", + "name": "Upper Profits Limit", + "orientation": "v", + "showlegend": true, + "type": "scatter", + "x": [ + "2015-04-06", + "2015-06-05", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", + "2026-04-06" + ], + "xaxis": "x", + "y": [ + 42386, + 43000, + 45000, + 46350, + 50000, + 50000, + 50270, + 50270 + ], + "yaxis": "y" + } + ], + "layout": { + "legend": { + "orientation": "h", + "title": { + "text": "Threshold Type" + }, + "tracegroupgap": 0, + "x": 0.05, + "xanchor": "left", + "y": 1.02, + "yanchor": "bottom" + }, + "template": { + "data": { + "bar": [ + { + "error_x": { + "color": "#2a3f5f" + }, + "error_y": { + "color": "#2a3f5f" + }, + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "bar" + } + ], + "barpolar": [ + { + "marker": { + "line": { + "color": "#E5ECF6", + "width": 0.5 + }, + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "barpolar" + } + ], + "carpet": [ + { + "aaxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "baxis": { + "endlinecolor": "#2a3f5f", + "gridcolor": "white", + "linecolor": "white", + "minorgridcolor": "white", + "startlinecolor": "#2a3f5f" + }, + "type": "carpet" + } + ], + "choropleth": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "choropleth" + } + ], + "contour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "contour" + } + ], + "contourcarpet": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "contourcarpet" + } + ], + "heatmap": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmap" + } + ], + "heatmapgl": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "heatmapgl" + } + ], + "histogram": [ + { + "marker": { + "pattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + } + }, + "type": "histogram" + } + ], + "histogram2d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2d" + } + ], + "histogram2dcontour": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "histogram2dcontour" + } + ], + "mesh3d": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "type": "mesh3d" + } + ], + "parcoords": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "parcoords" + } + ], + "pie": [ + { + "automargin": true, + "type": "pie" + } + ], + "scatter": [ + { + "fillpattern": { + "fillmode": "overlay", + "size": 10, + "solidity": 0.2 + }, + "type": "scatter" + } + ], + "scatter3d": [ + { + "line": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatter3d" + } + ], + "scattercarpet": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattercarpet" + } + ], + "scattergeo": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergeo" + } + ], + "scattergl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattergl" + } + ], + "scattermapbox": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scattermapbox" + } + ], + "scatterpolar": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolar" + } + ], + "scatterpolargl": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterpolargl" + } + ], + "scatterternary": [ + { + "marker": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "type": "scatterternary" + } + ], + "surface": [ + { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + }, + "colorscale": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "type": "surface" + } + ], + "table": [ + { + "cells": { + "fill": { + "color": "#EBF0F8" + }, + "line": { + "color": "white" + } + }, + "header": { + "fill": { + "color": "#C8D4E3" + }, + "line": { + "color": "white" + } + }, + "type": "table" + } + ] + }, + "layout": { + "annotationdefaults": { + "arrowcolor": "#2a3f5f", + "arrowhead": 0, + "arrowwidth": 1 + }, + "autotypenumbers": "strict", + "coloraxis": { + "colorbar": { + "outlinewidth": 0, + "ticks": "" + } + }, + "colorscale": { + "diverging": [ + [ + 0, + "#8e0152" + ], + [ + 0.1, + "#c51b7d" + ], + [ + 0.2, + "#de77ae" + ], + [ + 0.3, + "#f1b6da" + ], + [ + 0.4, + "#fde0ef" + ], + [ + 0.5, + "#f7f7f7" + ], + [ + 0.6, + "#e6f5d0" + ], + [ + 0.7, + "#b8e186" + ], + [ + 0.8, + "#7fbc41" + ], + [ + 0.9, + "#4d9221" + ], + [ + 1, + "#276419" + ] + ], + "sequential": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ], + "sequentialminus": [ + [ + 0, + "#0d0887" + ], + [ + 0.1111111111111111, + "#46039f" + ], + [ + 0.2222222222222222, + "#7201a8" + ], + [ + 0.3333333333333333, + "#9c179e" + ], + [ + 0.4444444444444444, + "#bd3786" + ], + [ + 0.5555555555555556, + "#d8576b" + ], + [ + 0.6666666666666666, + "#ed7953" + ], + [ + 0.7777777777777778, + "#fb9f3a" + ], + [ + 0.8888888888888888, + "#fdca26" + ], + [ + 1, + "#f0f921" + ] + ] + }, + "colorway": [ + "#636efa", + "#EF553B", + "#00cc96", + "#ab63fa", + "#FFA15A", + "#19d3f3", + "#FF6692", + "#B6E880", + "#FF97FF", + "#FECB52" + ], + "font": { + "color": "#2a3f5f" + }, + "geo": { + "bgcolor": "white", + "lakecolor": "white", + "landcolor": "#E5ECF6", + "showlakes": true, + "showland": true, + "subunitcolor": "white" + }, + "hoverlabel": { + "align": "left" + }, + "hovermode": "closest", + "mapbox": { + "style": "light" + }, + "paper_bgcolor": "white", + "plot_bgcolor": "#E5ECF6", + "polar": { + "angularaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "radialaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "scene": { + "xaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "yaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + }, + "zaxis": { + "backgroundcolor": "#E5ECF6", + "gridcolor": "white", + "gridwidth": 2, + "linecolor": "white", + "showbackground": true, + "ticks": "", + "zerolinecolor": "white" + } + }, + "shapedefaults": { + "line": { + "color": "#2a3f5f" + } + }, + "ternary": { + "aaxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "baxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + }, + "bgcolor": "#E5ECF6", + "caxis": { + "gridcolor": "white", + "linecolor": "white", + "ticks": "" + } + }, + "title": { + "x": 0.05 + }, + "xaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + }, + "yaxis": { + "automargin": true, + "gridcolor": "white", + "linecolor": "white", + "ticks": "", + "title": { + "standoff": 15 + }, + "zerolinecolor": "white", + "zerolinewidth": 2 + } + } + }, + "title": { + "text": "Class 4 National Insurance Thresholds Over Time" + }, + "xaxis": { + "anchor": "y", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Dates" + } + }, + "yaxis": { + "anchor": "x", + "domain": [ + 0, + 1 + ], + "title": { + "text": "Thresholds (GBP)" + } + } + } + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# @title\n", + "dates_lower_profits_limit = [\"2015-04-06\", \"2017-04-06\", \"2018-04-06\", \"2019-04-06\", \"2020-04-06\", \"2021-04-06\", \"2022-04-06\", \"2026-04-06\"]\n", + "values_lower_profits_limit = [8060, 8164, 8424, 8632, 9500, 9568, 11908, 12570]\n", + "\n", + "dates_upper_profits_limit = [\"2015-04-06\", \"2015-06-05\", \"2017-04-06\", \"2018-04-06\", \"2019-04-06\", \"2020-04-06\", \"2021-04-06\", \"2026-04-06\"]\n", + "values_upper_profits_limit = [42386, 43000, 45000, 46350, 50000, 50000, 50270, 50270]\n", + "\n", + "df_lower = pd.DataFrame({'Dates': dates_lower_profits_limit, 'Values': values_lower_profits_limit, 'Label': 'Lower Profits Limit'})\n", + "df_upper = pd.DataFrame({'Dates': dates_upper_profits_limit, 'Values': values_upper_profits_limit, 'Label': 'Upper Profits Limit'})\n", + "df = pd.concat([df_lower, df_upper])\n", + "\n", + "fig = px.line(df, x='Dates', y='Values', color='Label', title='Class 4 National Insurance Thresholds Over Time', markers=True)\n", + "\n", + "fig.update_layout(\n", + " xaxis_title=\"Dates\",\n", + " yaxis_title=\"Thresholds (GBP)\",\n", + " legend_title_text='Threshold Type',\n", + " legend=dict(orientation=\"h\", yanchor=\"bottom\", y=1.02, xanchor=\"left\", x=0.05)\n", + ")\n", + "\n", + "fig.show()\n" + ] + } + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "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.7" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +} From fcb384dcf574a8aedfd9a76f9f45eecbbc81d987 Mon Sep 17 00:00:00 2001 From: xiwang Date: Wed, 30 Aug 2023 18:31:01 -0400 Subject: [PATCH 2/4] update the tables --- ...surance.ipynb => national_insurance.ipynb} | 2496 +++-------------- 1 file changed, 320 insertions(+), 2176 deletions(-) rename docs/book/programs/gov/hmrc/{national-insurance.ipynb => national_insurance.ipynb} (67%) diff --git a/docs/book/programs/gov/hmrc/national-insurance.ipynb b/docs/book/programs/gov/hmrc/national_insurance.ipynb similarity index 67% rename from docs/book/programs/gov/hmrc/national-insurance.ipynb rename to docs/book/programs/gov/hmrc/national_insurance.ipynb index 635da4531..500a1346c 100644 --- a/docs/book/programs/gov/hmrc/national-insurance.ipynb +++ b/docs/book/programs/gov/hmrc/national_insurance.ipynb @@ -1,7 +1,6 @@ { "cells": [ { - "attachments": {}, "cell_type": "markdown", "metadata": { "id": "_gdKAFopTwuB" @@ -41,7 +40,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": { "cellView": "form", "colab": { @@ -113,20 +112,79 @@ }, "source": [ "# Appendix:\n", - "**- Class 1 National Insurance Rates:**" + "**- Class 1 National Insurance Rates:**\\\n", + "This table displays the parameter values for the Class 1 National Insurance rates for employees (both main and additional) and employers." ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, + "metadata": { + "cellView": "form", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "Qk95U6v2XqHR", + "outputId": "8551c5df-1844-4299-d52b-288e33dfd39a" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Date Class 1 Employee Main Rates Class 1 Employee Additional Rates Class 1 Employer Rates\n", + "2015-06-01 12.00% 2.00% 13.80%\n", + "2022-04-01 13.25% 3.25% \n", + "2022-11-06 12.00% \n" + ] + } + ], + "source": [ + "# @title\n", + "\n", + "main_dates = [\"2015-06-01\", \"2022-04-01\", \"2022-11-06\"]\n", + "main_rates = [0.12, 0.1325, 0.12]\n", + "\n", + "additional_dates = [\"2015-06-01\", \"2022-04-01\"]\n", + "additional_rates = [0.02, 0.0325]\n", + "\n", + "employer_dates = [\"2015-06-01\"]\n", + "employer_rates = [0.138]\n", + "\n", + "all_dates = sorted(set(main_dates + additional_dates + employer_dates))\n", + "\n", + "df = pd.DataFrame({'Date': all_dates})\n", + "df['Class 1 Employee Main Rates'] = df['Date'].map(dict(zip(main_dates, main_rates)))\n", + "df['Class 1 Employee Additional Rates'] = df['Date'].map(dict(zip(additional_dates, additional_rates)))\n", + "df['Class 1 Employer Rates'] = df['Date'].map(dict(zip(employer_dates, employer_rates)))\n", + "\n", + "df['Class 1 Employee Main Rates'] = df['Class 1 Employee Main Rates'].apply(lambda x: f\"{x*100:.2f}%\" if pd.notnull(x) else \"\")\n", + "df['Class 1 Employee Additional Rates'] = df['Class 1 Employee Additional Rates'].apply(lambda x: f\"{x*100:.2f}%\" if pd.notnull(x) else \"\")\n", + "df['Class 1 Employer Rates'] = df['Class 1 Employer Rates'].apply(lambda x: f\"{x*100:.2f}%\" if pd.notnull(x) else \"\")\n", + "\n", + "print(df.to_string(index=False))" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "sWgDc7c_2iVp" + }, + "source": [ + "**- Class 1 National Insurance Thresholds:**\n" + ] + }, + { + "cell_type": "code", + "execution_count": 3, "metadata": { "cellView": "form", "colab": { "base_uri": "https://localhost:8080/", "height": 542 }, - "id": "4XPp9G3Q4tbi", - "outputId": "1e4c9c0a-8f03-49ba-dcc0-d1f0ae9cbe45" + "id": "TMpoDSZP9Osd", + "outputId": "b771a3a2-14fe-4c66-8a9f-05c414f78954" }, "outputs": [ { @@ -137,2095 +195,163 @@ }, "data": [ { - "alignmentgroup": "True", - "hovertemplate": "Type=NI Class 1 Main Rate
Date=%{x}
Rates=%{y}", - "legendgroup": "NI Class 1 Main Rate", - "marker": { + "hovertemplate": "Thresholds=Lower Earnings Limit
Dates=%{x}
Thresholds (GBP)=%{y}", + "legendgroup": "Lower Earnings Limit", + "line": { "color": "#636efa", - "pattern": { - "shape": "" - } + "dash": "solid" + }, + "marker": { + "symbol": "circle" }, - "name": "NI Class 1 Main Rate", - "offsetgroup": "NI Class 1 Main Rate", + "mode": "lines", + "name": "Lower Earnings Limit", "orientation": "v", "showlegend": true, - "textposition": "auto", - "type": "bar", + "type": "scatter", "x": [ - "2015-06-01", - "2022-04-01", - "2022-11-06" + "2015-04-06", + "2016-04-06", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", + "2022-04-06" ], "xaxis": "x", "y": [ - 0.12, - 0.1325, - 0.12 + 112, + 112, + 113, + 116, + 118, + 120, + 120, + 123 ], "yaxis": "y" }, { - "alignmentgroup": "True", - "hovertemplate": "Type=NI Class 1 Additional Rate
Date=%{x}
Rates=%{y}", - "legendgroup": "NI Class 1 Additional Rate", - "marker": { + "hovertemplate": "Thresholds=Primary Threshold
Dates=%{x}
Thresholds (GBP)=%{y}", + "legendgroup": "Primary Threshold", + "line": { "color": "#EF553B", - "pattern": { - "shape": "" - } + "dash": "solid" }, - "name": "NI Class 1 Additional Rate", - "offsetgroup": "NI Class 1 Additional Rate", + "marker": { + "symbol": "circle" + }, + "mode": "lines", + "name": "Primary Threshold", "orientation": "v", "showlegend": true, - "textposition": "auto", - "type": "bar", + "type": "scatter", "x": [ - "2015-06-01", - "2022-04-01" + "2015-04-06", + "2016-04-06", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", + "2022-04-06" ], "xaxis": "x", "y": [ - 0.02, - 0.0325 + 155, + 155, + 157, + 162, + 166, + 183, + 184, + 190 ], "yaxis": "y" }, { - "alignmentgroup": "True", - "hovertemplate": "Type=NI Employer Rate
Date=%{x}
Rates=%{y}", - "legendgroup": "NI Employer Rate", - "marker": { + "hovertemplate": "Thresholds=Secondary Threshold
Dates=%{x}
Thresholds (GBP)=%{y}", + "legendgroup": "Secondary Threshold", + "line": { "color": "#00cc96", - "pattern": { - "shape": "" - } + "dash": "solid" }, - "name": "NI Employer Rate", - "offsetgroup": "NI Employer Rate", - "orientation": "v", - "showlegend": true, - "textposition": "auto", - "type": "bar", - "x": [ - "2015-06-01" - ], - "xaxis": "x", - "y": [ - 0.138 - ], - "yaxis": "y" - } - ], - "layout": { - "barmode": "relative", - "legend": { - "title": { - "text": "Type" + "marker": { + "symbol": "circle" }, - "tracegroupgap": 0 - }, - "template": { - "data": { - "bar": [ - { - "error_x": { - "color": "#2a3f5f" - }, - "error_y": { - "color": "#2a3f5f" - }, - "marker": { - "line": { - "color": "#E5ECF6", - "width": 0.5 - }, - "pattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - } - }, - "type": "bar" - } - ], - "barpolar": [ - { - "marker": { - "line": { - "color": "#E5ECF6", - "width": 0.5 - }, - "pattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - } - }, - "type": "barpolar" - } - ], - "carpet": [ - { - "aaxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" - }, - "baxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" - }, - "type": "carpet" - } - ], - "choropleth": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "type": "choropleth" - } - ], - "contour": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "contour" - } - ], - "contourcarpet": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "type": "contourcarpet" - } - ], - "heatmap": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "heatmap" - } - ], - "heatmapgl": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "heatmapgl" - } - ], - "histogram": [ - { - "marker": { - "pattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - } - }, - "type": "histogram" - } - ], - "histogram2d": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "histogram2d" - } - ], - "histogram2dcontour": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "histogram2dcontour" - } - ], - "mesh3d": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "type": "mesh3d" - } - ], - "parcoords": [ - { - "line": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "parcoords" - } - ], - "pie": [ - { - "automargin": true, - "type": "pie" - } - ], - "scatter": [ - { - "fillpattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - }, - "type": "scatter" - } - ], - "scatter3d": [ - { - "line": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatter3d" - } - ], - "scattercarpet": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattercarpet" - } - ], - "scattergeo": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattergeo" - } - ], - "scattergl": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattergl" - } - ], - "scattermapbox": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattermapbox" - } - ], - "scatterpolar": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatterpolar" - } - ], - "scatterpolargl": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatterpolargl" - } - ], - "scatterternary": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatterternary" - } - ], - "surface": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "surface" - } - ], - "table": [ - { - "cells": { - "fill": { - "color": "#EBF0F8" - }, - "line": { - "color": "white" - } - }, - "header": { - "fill": { - "color": "#C8D4E3" - }, - "line": { - "color": "white" - } - }, - "type": "table" - } - ] - }, - "layout": { - "annotationdefaults": { - "arrowcolor": "#2a3f5f", - "arrowhead": 0, - "arrowwidth": 1 - }, - "autotypenumbers": "strict", - "coloraxis": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "colorscale": { - "diverging": [ - [ - 0, - "#8e0152" - ], - [ - 0.1, - "#c51b7d" - ], - [ - 0.2, - "#de77ae" - ], - [ - 0.3, - "#f1b6da" - ], - [ - 0.4, - "#fde0ef" - ], - [ - 0.5, - "#f7f7f7" - ], - [ - 0.6, - "#e6f5d0" - ], - [ - 0.7, - "#b8e186" - ], - [ - 0.8, - "#7fbc41" - ], - [ - 0.9, - "#4d9221" - ], - [ - 1, - "#276419" - ] - ], - "sequential": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "sequentialminus": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ] - }, - "colorway": [ - "#636efa", - "#EF553B", - "#00cc96", - "#ab63fa", - "#FFA15A", - "#19d3f3", - "#FF6692", - "#B6E880", - "#FF97FF", - "#FECB52" - ], - "font": { - "color": "#2a3f5f" - }, - "geo": { - "bgcolor": "white", - "lakecolor": "white", - "landcolor": "#E5ECF6", - "showlakes": true, - "showland": true, - "subunitcolor": "white" - }, - "hoverlabel": { - "align": "left" - }, - "hovermode": "closest", - "mapbox": { - "style": "light" - }, - "paper_bgcolor": "white", - "plot_bgcolor": "#E5ECF6", - "polar": { - "angularaxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - }, - "bgcolor": "#E5ECF6", - "radialaxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - } - }, - "scene": { - "xaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", - "gridwidth": 2, - "linecolor": "white", - "showbackground": true, - "ticks": "", - "zerolinecolor": "white" - }, - "yaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", - "gridwidth": 2, - "linecolor": "white", - "showbackground": true, - "ticks": "", - "zerolinecolor": "white" - }, - "zaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", - "gridwidth": 2, - "linecolor": "white", - "showbackground": true, - "ticks": "", - "zerolinecolor": "white" - } - }, - "shapedefaults": { - "line": { - "color": "#2a3f5f" - } - }, - "ternary": { - "aaxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - }, - "baxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - }, - "bgcolor": "#E5ECF6", - "caxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - } - }, - "title": { - "x": 0.05 - }, - "xaxis": { - "automargin": true, - "gridcolor": "white", - "linecolor": "white", - "ticks": "", - "title": { - "standoff": 15 - }, - "zerolinecolor": "white", - "zerolinewidth": 2 - }, - "yaxis": { - "automargin": true, - "gridcolor": "white", - "linecolor": "white", - "ticks": "", - "title": { - "standoff": 15 - }, - "zerolinecolor": "white", - "zerolinewidth": 2 - } - } - }, - "title": { - "text": "Class 1 National Insurance Rates Over Time" - }, - "xaxis": { - "anchor": "y", - "domain": [ - 0, - 1 - ], - "title": { - "text": "Date" - } - }, - "yaxis": { - "anchor": "x", - "domain": [ - 0, - 1 - ], - "title": { - "text": "Rates" - } - } - } - } - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# @title\n", - "import plotly.express as px\n", - "\n", - "dates_employee_additional = [\"2015-06-01\", \"2022-04-01\"]\n", - "rates_employee_additional = [0.02, 0.0325]\n", - "\n", - "dates_employee_main = [\"2015-06-01\", \"2022-04-01\", \"2022-11-06\"]\n", - "rates_employee_main = [0.12, 0.1325, 0.12]\n", - "\n", - "dates_employer = [\"2015-06-01\"]\n", - "rates_employer = [0.138]\n", - "\n", - "dates = sorted(set(dates_employee_additional + dates_employee_main + dates_employer))\n", - "df_employee_additional = pd.DataFrame({'Date': dates_employee_additional, 'Rate': rates_employee_additional, 'Type': 'NI Class 1 Additional Rate'})\n", - "df_employee_main = pd.DataFrame({'Date': dates_employee_main, 'Rate': rates_employee_main, 'Type': 'NI Class 1 Main Rate'})\n", - "df_employer = pd.DataFrame({'Date': dates_employer, 'Rate': rates_employer, 'Type': 'NI Employer Rate'})\n", - "\n", - "df = pd.concat([df_employee_main, df_employee_additional, df_employer], ignore_index=True)\n", - "\n", - "fig = px.bar(df, x='Date', y='Rate', color='Type',\n", - " title='Class 1 National Insurance Rates',\n", - " labels={'Date': 'Date', 'Rate': 'Rates'},\n", - " category_orders={\"Type\": [\"NI Class 1 Main Rate\", \"NI Class 1 Additional Rate\", \"NI Employer Rate\"]})\n", - "\n", - "fig.show()\n", - "\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "sWgDc7c_2iVp" - }, - "source": [ - "**- Class 1 National Insurance Thresholds:**\n" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": { - "cellView": "form", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 542 - }, - "id": "TMpoDSZP9Osd", - "outputId": "b771a3a2-14fe-4c66-8a9f-05c414f78954" - }, - "outputs": [ - { - "data": { - "application/vnd.plotly.v1+json": { - "config": { - "plotlyServerURL": "https://plot.ly" - }, - "data": [ - { - "hovertemplate": "Thresholds=Lower Earnings Limit
Dates=%{x}
Thresholds (GBP)=%{y}", - "legendgroup": "Lower Earnings Limit", - "line": { - "color": "#636efa", - "dash": "solid" - }, - "marker": { - "symbol": "circle" - }, - "mode": "lines", - "name": "Lower Earnings Limit", - "orientation": "v", - "showlegend": true, - "type": "scatter", - "x": [ - "2015-04-06", - "2016-04-06", - "2017-04-06", - "2018-04-06", - "2019-04-06", - "2020-04-06", - "2021-04-06", - "2022-04-06" - ], - "xaxis": "x", - "y": [ - 112, - 112, - 113, - 116, - 118, - 120, - 120, - 123 - ], - "yaxis": "y" - }, - { - "hovertemplate": "Thresholds=Primary Threshold
Dates=%{x}
Thresholds (GBP)=%{y}", - "legendgroup": "Primary Threshold", - "line": { - "color": "#EF553B", - "dash": "solid" - }, - "marker": { - "symbol": "circle" - }, - "mode": "lines", - "name": "Primary Threshold", - "orientation": "v", - "showlegend": true, - "type": "scatter", - "x": [ - "2015-04-06", - "2016-04-06", - "2017-04-06", - "2018-04-06", - "2019-04-06", - "2020-04-06", - "2021-04-06", - "2022-04-06" - ], - "xaxis": "x", - "y": [ - 155, - 155, - 157, - 162, - 166, - 183, - 184, - 190 - ], - "yaxis": "y" - }, - { - "hovertemplate": "Thresholds=Secondary Threshold
Dates=%{x}
Thresholds (GBP)=%{y}", - "legendgroup": "Secondary Threshold", - "line": { - "color": "#00cc96", - "dash": "solid" - }, - "marker": { - "symbol": "circle" - }, - "mode": "lines", - "name": "Secondary Threshold", - "orientation": "v", - "showlegend": true, - "type": "scatter", - "x": [ - "2015-04-06", - "2016-04-06", - "2017-04-06", - "2018-04-06", - "2019-04-06", - "2020-04-06", - "2021-04-06", - "2022-04-06" - ], - "xaxis": "x", - "y": [ - 155, - 155, - 157, - 162, - 166, - 169, - 170, - 175 - ], - "yaxis": "y" - }, - { - "hovertemplate": "Thresholds=Upper Earnings Limit
Dates=%{x}
Thresholds (GBP)=%{y}", - "legendgroup": "Upper Earnings Limit", - "line": { - "color": "#ab63fa", - "dash": "solid" - }, - "marker": { - "symbol": "circle" - }, - "mode": "lines", - "name": "Upper Earnings Limit", - "orientation": "v", - "showlegend": true, - "type": "scatter", - "x": [ - "2015-04-06", - "2016-04-06", - "2017-04-06", - "2018-04-06", - "2019-04-06", - "2020-04-06", - "2021-04-06", - "2022-04-06" - ], - "xaxis": "x", - "y": [ - 815, - 827, - 866, - 892, - 962, - 962, - 966.73, - 966.73 - ], - "yaxis": "y" - } - ], - "layout": { - "legend": { - "title": { - "text": "Thresholds" - }, - "tracegroupgap": 0 - }, - "template": { - "data": { - "bar": [ - { - "error_x": { - "color": "#2a3f5f" - }, - "error_y": { - "color": "#2a3f5f" - }, - "marker": { - "line": { - "color": "#E5ECF6", - "width": 0.5 - }, - "pattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - } - }, - "type": "bar" - } - ], - "barpolar": [ - { - "marker": { - "line": { - "color": "#E5ECF6", - "width": 0.5 - }, - "pattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - } - }, - "type": "barpolar" - } - ], - "carpet": [ - { - "aaxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" - }, - "baxis": { - "endlinecolor": "#2a3f5f", - "gridcolor": "white", - "linecolor": "white", - "minorgridcolor": "white", - "startlinecolor": "#2a3f5f" - }, - "type": "carpet" - } - ], - "choropleth": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "type": "choropleth" - } - ], - "contour": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "contour" - } - ], - "contourcarpet": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "type": "contourcarpet" - } - ], - "heatmap": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "heatmap" - } - ], - "heatmapgl": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "heatmapgl" - } - ], - "histogram": [ - { - "marker": { - "pattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - } - }, - "type": "histogram" - } - ], - "histogram2d": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "histogram2d" - } - ], - "histogram2dcontour": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "histogram2dcontour" - } - ], - "mesh3d": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "type": "mesh3d" - } - ], - "parcoords": [ - { - "line": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "parcoords" - } - ], - "pie": [ - { - "automargin": true, - "type": "pie" - } - ], - "scatter": [ - { - "fillpattern": { - "fillmode": "overlay", - "size": 10, - "solidity": 0.2 - }, - "type": "scatter" - } - ], - "scatter3d": [ - { - "line": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatter3d" - } - ], - "scattercarpet": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattercarpet" - } - ], - "scattergeo": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattergeo" - } - ], - "scattergl": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattergl" - } - ], - "scattermapbox": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scattermapbox" - } - ], - "scatterpolar": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatterpolar" - } - ], - "scatterpolargl": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatterpolargl" - } - ], - "scatterternary": [ - { - "marker": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "type": "scatterternary" - } - ], - "surface": [ - { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - }, - "colorscale": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "type": "surface" - } - ], - "table": [ - { - "cells": { - "fill": { - "color": "#EBF0F8" - }, - "line": { - "color": "white" - } - }, - "header": { - "fill": { - "color": "#C8D4E3" - }, - "line": { - "color": "white" - } - }, - "type": "table" - } - ] - }, - "layout": { - "annotationdefaults": { - "arrowcolor": "#2a3f5f", - "arrowhead": 0, - "arrowwidth": 1 - }, - "autotypenumbers": "strict", - "coloraxis": { - "colorbar": { - "outlinewidth": 0, - "ticks": "" - } - }, - "colorscale": { - "diverging": [ - [ - 0, - "#8e0152" - ], - [ - 0.1, - "#c51b7d" - ], - [ - 0.2, - "#de77ae" - ], - [ - 0.3, - "#f1b6da" - ], - [ - 0.4, - "#fde0ef" - ], - [ - 0.5, - "#f7f7f7" - ], - [ - 0.6, - "#e6f5d0" - ], - [ - 0.7, - "#b8e186" - ], - [ - 0.8, - "#7fbc41" - ], - [ - 0.9, - "#4d9221" - ], - [ - 1, - "#276419" - ] - ], - "sequential": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ], - "sequentialminus": [ - [ - 0, - "#0d0887" - ], - [ - 0.1111111111111111, - "#46039f" - ], - [ - 0.2222222222222222, - "#7201a8" - ], - [ - 0.3333333333333333, - "#9c179e" - ], - [ - 0.4444444444444444, - "#bd3786" - ], - [ - 0.5555555555555556, - "#d8576b" - ], - [ - 0.6666666666666666, - "#ed7953" - ], - [ - 0.7777777777777778, - "#fb9f3a" - ], - [ - 0.8888888888888888, - "#fdca26" - ], - [ - 1, - "#f0f921" - ] - ] - }, - "colorway": [ - "#636efa", - "#EF553B", - "#00cc96", - "#ab63fa", - "#FFA15A", - "#19d3f3", - "#FF6692", - "#B6E880", - "#FF97FF", - "#FECB52" - ], - "font": { - "color": "#2a3f5f" - }, - "geo": { - "bgcolor": "white", - "lakecolor": "white", - "landcolor": "#E5ECF6", - "showlakes": true, - "showland": true, - "subunitcolor": "white" - }, - "hoverlabel": { - "align": "left" - }, - "hovermode": "closest", - "mapbox": { - "style": "light" - }, - "paper_bgcolor": "white", - "plot_bgcolor": "#E5ECF6", - "polar": { - "angularaxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - }, - "bgcolor": "#E5ECF6", - "radialaxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - } - }, - "scene": { - "xaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", - "gridwidth": 2, - "linecolor": "white", - "showbackground": true, - "ticks": "", - "zerolinecolor": "white" - }, - "yaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", - "gridwidth": 2, - "linecolor": "white", - "showbackground": true, - "ticks": "", - "zerolinecolor": "white" - }, - "zaxis": { - "backgroundcolor": "#E5ECF6", - "gridcolor": "white", - "gridwidth": 2, - "linecolor": "white", - "showbackground": true, - "ticks": "", - "zerolinecolor": "white" - } - }, - "shapedefaults": { - "line": { - "color": "#2a3f5f" - } - }, - "ternary": { - "aaxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - }, - "baxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - }, - "bgcolor": "#E5ECF6", - "caxis": { - "gridcolor": "white", - "linecolor": "white", - "ticks": "" - } - }, - "title": { - "x": 0.05 - }, - "xaxis": { - "automargin": true, - "gridcolor": "white", - "linecolor": "white", - "ticks": "", - "title": { - "standoff": 15 - }, - "zerolinecolor": "white", - "zerolinewidth": 2 - }, - "yaxis": { - "automargin": true, - "gridcolor": "white", - "linecolor": "white", - "ticks": "", - "title": { - "standoff": 15 - }, - "zerolinecolor": "white", - "zerolinewidth": 2 - } - } - }, - "title": { - "text": "Class 1 National Insurance Thresholds Over Time" - }, - "xaxis": { - "anchor": "y", - "domain": [ - 0, - 1 - ], - "title": { - "text": "Dates" - } - }, - "yaxis": { - "anchor": "x", - "domain": [ - 0, - 1 - ], - "title": { - "text": "Thresholds (GBP)" - } - } - } - } - }, - "metadata": {}, - "output_type": "display_data" - } - ], - "source": [ - "# @title\n", - "dates = ['2015-04-06', '2016-04-06', '2017-04-06', '2018-04-06', '2019-04-06', '2020-04-06', '2021-04-06', '2022-04-06']\n", - "\n", - "lower_earnings = [112, 112, 113, 116, 118, 120, 120, 123]\n", - "primary_threshold = [155, 155, 157, 162, 166, 183, 184, 190]\n", - "secondary_threshold = [155, 155, 157, 162, 166, 169, 170, 175]\n", - "upper_earnings = [815, 827, 866, 892, 962, 962, 966.73, 966.73]\n", - "\n", - "df = pd.DataFrame({\n", - " 'Dates': dates,\n", - " 'Lower Earnings Limit': lower_earnings,\n", - " 'Primary Threshold': primary_threshold,\n", - " 'Secondary Threshold': secondary_threshold,\n", - " 'Upper Earnings Limit': upper_earnings\n", - "})\n", - "\n", - "fig = px.line(df, x='Dates', y=df.columns[1:],\n", - " title='Class 1 National Insurance Thresholds Over Time',\n", - " labels={'value': 'Thresholds (GBP)', 'variable': 'Thresholds', 'Dates': 'Dates'})\n", - "\n", - "fig.show()\n" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "ePYoUq0Y3XLb" - }, - "source": [ - "**- Class 2 National Insurance Rates:**" - ] - }, - { - "cell_type": "code", - "execution_count": 6, - "metadata": { - "cellView": "form", - "colab": { - "base_uri": "https://localhost:8080/", - "height": 542 - }, - "id": "2nnoLaMakEsZ", - "outputId": "e4fc445f-48b7-46eb-ce6e-4b9e14e36c18" - }, - "outputs": [ - { - "data": { - "application/vnd.plotly.v1+json": { - "config": { - "plotlyServerURL": "https://plot.ly" - }, - "data": [ + "mode": "lines", + "name": "Secondary Threshold", + "orientation": "v", + "showlegend": true, + "type": "scatter", + "x": [ + "2015-04-06", + "2016-04-06", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", + "2022-04-06" + ], + "xaxis": "x", + "y": [ + 155, + 155, + 157, + 162, + 166, + 169, + 170, + 175 + ], + "yaxis": "y" + }, { - "hovertemplate": "Dates=%{x}
Flat rate (GBP)=%{y}", - "legendgroup": "", + "hovertemplate": "Thresholds=Upper Earnings Limit
Dates=%{x}
Thresholds (GBP)=%{y}", + "legendgroup": "Upper Earnings Limit", "line": { - "color": "blue", + "color": "#ab63fa", "dash": "solid" }, "marker": { "symbol": "circle" }, - "mode": "lines+markers", - "name": "", + "mode": "lines", + "name": "Upper Earnings Limit", "orientation": "v", - "showlegend": false, + "showlegend": true, "type": "scatter", "x": [ - "2015-06-01", - "2017-06-01", - "2018-06-01", - "2019-06-01", - "2020-06-01", + "2015-04-06", + "2016-04-06", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", "2022-04-06" ], "xaxis": "x", "y": [ - 2.8, - 2.85, - 2.95, - 3, - 3.05, - 3.15 + 815, + 827, + 866, + 892, + 962, + 962, + 966.73, + 966.73 ], "yaxis": "y" } ], "layout": { "legend": { + "title": { + "text": "Thresholds" + }, "tracegroupgap": 0 }, "template": { @@ -3045,7 +1171,7 @@ } }, "title": { - "text": "Class 2 National Insurance: Flat rate" + "text": "Class 1 National Insurance Thresholds Over Time" }, "xaxis": { "anchor": "y", @@ -3064,7 +1190,7 @@ 1 ], "title": { - "text": "Flat rate (GBP)" + "text": "Thresholds (GBP)" } } } @@ -3076,42 +1202,50 @@ ], "source": [ "# @title\n", + "import plotly.express as px\n", "\n", - "dates_flat_rate = ['2015-06-01', '2017-06-01', '2018-06-01', '2019-06-01', '2020-06-01', '2022-04-06']\n", - "flat_rate_values = [2.80, 2.85, 2.95, 3.00, 3.05, 3.15]\n", - "df_flat_rate = pd.DataFrame({'Dates': dates_flat_rate, 'Flat rate': flat_rate_values})\n", + "dates = ['2015-04-06', '2016-04-06', '2017-04-06', '2018-04-06', '2019-04-06', '2020-04-06', '2021-04-06', '2022-04-06']\n", "\n", - "dates_small_profits = ['2015-04-06', '2017-04-06', '2018-04-06', '2019-04-06', '2020-04-06', '2021-04-06', '2022-04-06']\n", - "small_profits_values = [3965, 6025, 6205, 6365, 6475, 6515, 6725]\n", - "df_small_profits = pd.DataFrame({'Dates': dates_small_profits, 'Small profits threshold': small_profits_values})\n", + "lower_earnings = [112, 112, 113, 116, 118, 120, 120, 123]\n", + "primary_threshold = [155, 155, 157, 162, 166, 183, 184, 190]\n", + "secondary_threshold = [155, 155, 157, 162, 166, 169, 170, 175]\n", + "upper_earnings = [815, 827, 866, 892, 962, 962, 966.73, 966.73]\n", "\n", - "fig_flat_rate = px.line(df_flat_rate, x='Dates', y='Flat rate',\n", - " title='Class 2 National Insurance: Flat rate',\n", - " labels={'Dates': 'Dates', 'Flat rate': 'Flat rate (GBP)'},\n", - " markers=True, color_discrete_sequence=['blue'])\n", - "fig_flat_rate.show()\n" + "df = pd.DataFrame({\n", + " 'Dates': dates,\n", + " 'Lower Earnings Limit': lower_earnings,\n", + " 'Primary Threshold': primary_threshold,\n", + " 'Secondary Threshold': secondary_threshold,\n", + " 'Upper Earnings Limit': upper_earnings\n", + "})\n", + "\n", + "fig = px.line(df, x='Dates', y=df.columns[1:],\n", + " title='Class 1 National Insurance Thresholds Over Time',\n", + " labels={'value': 'Thresholds (GBP)', 'variable': 'Thresholds', 'Dates': 'Dates'})\n", + "\n", + "fig.show()\n" ] }, { "cell_type": "markdown", "metadata": { - "id": "nu9MatvD34bc" + "id": "ePYoUq0Y3XLb" }, "source": [ - "**- Class 2 National Insurance Thresholds**" + "**- Class 2 National Insurance Rates:**" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 4, "metadata": { "cellView": "form", "colab": { "base_uri": "https://localhost:8080/", "height": 542 }, - "id": "THpgsF7A309V", - "outputId": "4261ff0f-8da0-4b70-ef71-a32ede36a2e9" + "id": "2nnoLaMakEsZ", + "outputId": "e4fc445f-48b7-46eb-ce6e-4b9e14e36c18" }, "outputs": [ { @@ -3122,38 +1256,36 @@ }, "data": [ { - "hovertemplate": "Dates=%{x}
Small profits threshold (GBP)=%{y}", + "hovertemplate": "Dates=%{x}
Flat rate (GBP)=%{y}", "legendgroup": "", "line": { - "color": "red", + "color": "blue", "dash": "solid" }, "marker": { "symbol": "circle" }, - "mode": "lines+markers", + "mode": "markers+lines", "name": "", "orientation": "v", "showlegend": false, "type": "scatter", "x": [ - "2015-04-06", - "2017-04-06", - "2018-04-06", - "2019-04-06", - "2020-04-06", - "2021-04-06", + "2015-06-01", + "2017-06-01", + "2018-06-01", + "2019-06-01", + "2020-06-01", "2022-04-06" ], "xaxis": "x", "y": [ - 3965, - 6025, - 6205, - 6365, - 6475, - 6515, - 6725 + 2.8, + 2.85, + 2.95, + 3, + 3.05, + 3.15 ], "yaxis": "y" } @@ -3979,7 +2111,7 @@ } }, "title": { - "text": "Class 2 National Insurance: Small profits threshold" + "text": "Class 2 National Insurance: Flat rate" }, "xaxis": { "anchor": "y", @@ -3998,7 +2130,7 @@ 1 ], "title": { - "text": "Small profits threshold (GBP)" + "text": "Flat rate (GBP)" } } } @@ -4010,33 +2142,42 @@ ], "source": [ "# @title\n", - "fig_small_profits = px.line(df_small_profits, x='Dates', y='Small profits threshold',\n", - " title='Class 2 National Insurance: Small profits threshold',\n", - " labels={'Dates': 'Dates', 'Small profits threshold': 'Small profits threshold (GBP)'},\n", - " markers=True, color_discrete_sequence=['red'])\n", - "fig_small_profits.show()\n" + "\n", + "dates_flat_rate = ['2015-06-01', '2017-06-01', '2018-06-01', '2019-06-01', '2020-06-01', '2022-04-06']\n", + "flat_rate_values = [2.80, 2.85, 2.95, 3.00, 3.05, 3.15]\n", + "df_flat_rate = pd.DataFrame({'Dates': dates_flat_rate, 'Flat rate': flat_rate_values})\n", + "\n", + "dates_small_profits = ['2015-04-06', '2017-04-06', '2018-04-06', '2019-04-06', '2020-04-06', '2021-04-06', '2022-04-06']\n", + "small_profits_values = [3965, 6025, 6205, 6365, 6475, 6515, 6725]\n", + "df_small_profits = pd.DataFrame({'Dates': dates_small_profits, 'Small profits threshold': small_profits_values})\n", + "\n", + "fig_flat_rate = px.line(df_flat_rate, x='Dates', y='Flat rate',\n", + " title='Class 2 National Insurance: Flat rate',\n", + " labels={'Dates': 'Dates', 'Flat rate': 'Flat rate (GBP)'},\n", + " markers=True, color_discrete_sequence=['blue'])\n", + "fig_flat_rate.show()\n" ] }, { "cell_type": "markdown", "metadata": { - "id": "WCMSiBiz4Dzq" + "id": "nu9MatvD34bc" }, "source": [ - "**- Class 4 National Insurance Rates:**" + "**- Class 2 National Insurance Thresholds**" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 5, "metadata": { "cellView": "form", "colab": { "base_uri": "https://localhost:8080/", "height": 542 }, - "id": "IkPwua4Rmi-7", - "outputId": "1e254d6e-5971-4f22-8828-ddd9c13363fd" + "id": "THpgsF7A309V", + "outputId": "4261ff0f-8da0-4b70-ef71-a32ede36a2e9" }, "outputs": [ { @@ -4047,69 +2188,44 @@ }, "data": [ { - "alignmentgroup": "True", - "hovertemplate": "Rate Type=Class 4 Main Rate
Date=%{x}
Rates=%{y}", - "legendgroup": "Class 4 Main Rate", - "marker": { - "color": "#636efa", - "pattern": { - "shape": "" - } + "hovertemplate": "Dates=%{x}
Small profits threshold (GBP)=%{y}", + "legendgroup": "", + "line": { + "color": "red", + "dash": "solid" }, - "name": "Class 4 Main Rate", - "offsetgroup": "Class 4 Main Rate", - "orientation": "v", - "showlegend": true, - "textposition": "auto", - "type": "bar", - "x": [ - "2015-06-01", - "2022-04-01", - "2022-11-06" - ], - "xaxis": "x", - "y": [ - 0.09, - 0.1025, - 0.09 - ], - "yaxis": "y" - }, - { - "alignmentgroup": "True", - "hovertemplate": "Rate Type=Class 4 Additional Rate
Date=%{x}
Rates=%{y}", - "legendgroup": "Class 4 Additional Rate", "marker": { - "color": "#EF553B", - "pattern": { - "shape": "" - } + "symbol": "circle" }, - "name": "Class 4 Additional Rate", - "offsetgroup": "Class 4 Additional Rate", + "mode": "markers+lines", + "name": "", "orientation": "v", - "showlegend": true, - "textposition": "auto", - "type": "bar", + "showlegend": false, + "type": "scatter", "x": [ - "2015-06-01", - "2022-04-01" + "2015-04-06", + "2017-04-06", + "2018-04-06", + "2019-04-06", + "2020-04-06", + "2021-04-06", + "2022-04-06" ], "xaxis": "x", "y": [ - 0.02, - 0.035 + 3965, + 6025, + 6205, + 6365, + 6475, + 6515, + 6725 ], "yaxis": "y" } ], "layout": { - "bargap": 0.8, - "barmode": "relative", "legend": { - "title": { - "text": "Rate Type" - }, "tracegroupgap": 0 }, "template": { @@ -4929,7 +3045,7 @@ } }, "title": { - "text": "Class 4 National Insurance Rates Over Time" + "text": "Class 2 National Insurance: Small profits threshold" }, "xaxis": { "anchor": "y", @@ -4938,9 +3054,8 @@ 1 ], "title": { - "text": "Date" - }, - "type": "category" + "text": "Dates" + } }, "yaxis": { "anchor": "x", @@ -4949,7 +3064,7 @@ 1 ], "title": { - "text": "Rates" + "text": "Small profits threshold (GBP)" } } } @@ -4959,39 +3074,67 @@ "output_type": "display_data" } ], + "source": [ + "# @title\n", + "fig_small_profits = px.line(df_small_profits, x='Dates', y='Small profits threshold',\n", + " title='Class 2 National Insurance: Small profits threshold',\n", + " labels={'Dates': 'Dates', 'Small profits threshold': 'Small profits threshold (GBP)'},\n", + " markers=True, color_discrete_sequence=['red'])\n", + "fig_small_profits.show()\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "WCMSiBiz4Dzq" + }, + "source": [ + "**- Class 4 National Insurance Rates:**\\\n", + "This table displays the parameter values for the Class 4 National Insurance rates (both main and additional).\n" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "cellView": "form", + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "F4oIyDVIgTeC", + "outputId": "6adafe10-779d-4779-82cc-aa6ae4f5fbf4" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " Date Class 4 Main Rate Class 4 Additional Rate\n", + "2015-06-01 9.00% 2.00%\n", + "2022-04-01 10.25% 3.50%\n", + "2022-11-06 9.00% \n" + ] + } + ], "source": [ "# @title\n", "\n", - "dates_main = [\"2015-06-01\", \"2022-04-01\", \"2022-11-06\"]\n", - "rates_main = [0.09, 0.1025, 0.09]\n", - "\n", - "dates_additional = [\"2015-06-01\", \"2022-04-01\"]\n", - "rates_additional = [0.02, 0.035]\n", - "\n", - "df_main = pd.DataFrame({\n", - " 'Date': dates_main,\n", - " 'Rate': rates_main,\n", - " 'Rate Type': 'Class 4 Main Rate'\n", - "})\n", + "main_dates = [\"2015-06-01\", \"2022-04-01\", \"2022-11-06\"]\n", + "main_rates = [0.09, 0.1025, 0.09]\n", "\n", - "df_additional = pd.DataFrame({\n", - " 'Date': dates_additional,\n", - " 'Rate': rates_additional,\n", - " 'Rate Type': 'Class 4 Additional Rate'\n", - "})\n", + "additional_dates = [\"2015-06-01\", \"2022-04-01\"]\n", + "additional_rates = [0.02, 0.035]\n", "\n", - "df = pd.concat([df_main, df_additional], ignore_index=True)\n", + "all_dates = sorted(set(main_dates + additional_dates))\n", "\n", - "fig = px.bar(df, x='Date', y='Rate', color='Rate Type',\n", - " title='Class 4 National Insurance Rates Over Time',\n", - " labels={'Date': 'Date', 'Rate': 'Rates'},\n", - " category_orders={\"Rate Type\": [\"Class 4 Main Rate\", \"Class 4 Additional Rate\"]})\n", + "df = pd.DataFrame({'Date': all_dates})\n", + "df['Class 4 Main Rate'] = df['Date'].map(dict(zip(main_dates, main_rates)))\n", + "df['Class 4 Additional Rate'] = df['Date'].map(dict(zip(additional_dates, additional_rates)))\n", "\n", - "fig.update_layout(bargap=0.8)\n", - "fig.update_xaxes(type='category')\n", + "df['Class 4 Main Rate'] = df['Class 4 Main Rate'].apply(lambda x: f\"{x*100:.2f}%\" if pd.notnull(x) else \"\")\n", + "df['Class 4 Additional Rate'] = df['Class 4 Additional Rate'].apply(lambda x: f\"{x*100:.2f}%\" if pd.notnull(x) else \"\")\n", "\n", - "fig.show()\n", - "\n" + "print(df.to_string(index=False))\n" ] }, { @@ -5005,7 +3148,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "metadata": { "cellView": "form", "colab": { @@ -5033,7 +3176,7 @@ "marker": { "symbol": "circle" }, - "mode": "lines+markers", + "mode": "markers+lines", "name": "Lower Profits Limit", "orientation": "v", "showlegend": true, @@ -5071,7 +3214,7 @@ "marker": { "symbol": "circle" }, - "mode": "lines+markers", + "mode": "markers+lines", "name": "Upper Profits Limit", "orientation": "v", "showlegend": true, @@ -5960,6 +4103,7 @@ ], "source": [ "# @title\n", + "\n", "dates_lower_profits_limit = [\"2015-04-06\", \"2017-04-06\", \"2018-04-06\", \"2019-04-06\", \"2020-04-06\", \"2021-04-06\", \"2022-04-06\", \"2026-04-06\"]\n", "values_lower_profits_limit = [8060, 8164, 8424, 8632, 9500, 9568, 11908, 12570]\n", "\n", From f727218c962ac43521185679978193dc5cf2aa9d Mon Sep 17 00:00:00 2001 From: xiwang Date: Wed, 30 Aug 2023 18:35:03 -0400 Subject: [PATCH 3/4] update changelog --- changelog_entry.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..29c7971e5 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: minor + changes: + added: + - Update National Insurance documentation \ No newline at end of file From 6b1a7353efa700e39bad144119f9ed05a2b0afb1 Mon Sep 17 00:00:00 2001 From: xiwang Date: Wed, 30 Aug 2023 18:43:45 -0400 Subject: [PATCH 4/4] adjust indent --- changelog_entry.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index 29c7971e5..37daeef19 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -1,4 +1,4 @@ - bump: minor changes: added: - - Update National Insurance documentation \ No newline at end of file + - Update National Insurance documentation