{ "cells": [ { "cell_type": "markdown", "id": "e93d157f-29f0-4191-80c1-147920f90212", "metadata": { "tags": [] }, "source": [ "## Court Caseload Extract" ] }, { "cell_type": "code", "execution_count": 8, "id": "265a68e5-bf04-468a-ae79-a58d0a79f6bf", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: pydbtools in /opt/conda/lib/python3.9/site-packages (5.6.4)\n", "Requirement already satisfied: sql-metadata<3.0.0,>=2.3.0 in /opt/conda/lib/python3.9/site-packages (from pydbtools) (2.15.0)\n", "Requirement already satisfied: awswrangler>=2.12.0 in /opt/conda/lib/python3.9/site-packages (from pydbtools) (3.11.0)\n", "Requirement already satisfied: sqlparse>=0.5.0 in /opt/conda/lib/python3.9/site-packages (from pydbtools) (0.5.3)\n", "Requirement already satisfied: pyarrow>=14.0.0 in /opt/conda/lib/python3.9/site-packages (from pydbtools) (18.1.0)\n", "Requirement already satisfied: Jinja2>=3.1.0 in /opt/conda/lib/python3.9/site-packages (from pydbtools) (3.1.6)\n", "Requirement already satisfied: boto3>=1.7.4 in /opt/conda/lib/python3.9/site-packages (from pydbtools) (1.24.82)\n", "Requirement already satisfied: arrow-pd-parser>=1.3.9 in /opt/conda/lib/python3.9/site-packages (from pydbtools) (2.2.0)\n", "Requirement already satisfied: mojap-metadata[arrow]<2.0.0,>=1.10.0 in /opt/conda/lib/python3.9/site-packages (from arrow-pd-parser>=1.3.9->pydbtools) (1.15.3)\n", "Requirement already satisfied: pandas>=1.2 in /opt/conda/lib/python3.9/site-packages (from arrow-pd-parser>=1.3.9->pydbtools) (1.3.3)\n", "Requirement already satisfied: smart-open<6.0.0,>=5.2.1 in /opt/conda/lib/python3.9/site-packages (from arrow-pd-parser>=1.3.9->pydbtools) (5.2.1)\n", "Collecting numpy<2.1.0,>=1.26\n", " Using cached numpy-2.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (19.5 MB)\n", "Requirement already satisfied: typing-extensions<5.0.0,>=4.4.0 in /opt/conda/lib/python3.9/site-packages (from awswrangler>=2.12.0->pydbtools) (4.12.2)\n", "Requirement already satisfied: botocore<2.0.0,>=1.23.32 in /opt/conda/lib/python3.9/site-packages (from awswrangler>=2.12.0->pydbtools) (1.27.82)\n", "Requirement already satisfied: packaging<25.0,>=21.1 in /opt/conda/lib/python3.9/site-packages (from awswrangler>=2.12.0->pydbtools) (24.2)\n", "Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in /opt/conda/lib/python3.9/site-packages (from boto3>=1.7.4->pydbtools) (1.0.1)\n", "Requirement already satisfied: s3transfer<0.7.0,>=0.6.0 in /opt/conda/lib/python3.9/site-packages (from boto3>=1.7.4->pydbtools) (0.6.0)\n", "Requirement already satisfied: urllib3<1.27,>=1.25.4 in /opt/conda/lib/python3.9/site-packages (from botocore<2.0.0,>=1.23.32->awswrangler>=2.12.0->pydbtools) (1.26.6)\n", "Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in /opt/conda/lib/python3.9/site-packages (from botocore<2.0.0,>=1.23.32->awswrangler>=2.12.0->pydbtools) (2.8.2)\n", "Requirement already satisfied: MarkupSafe>=2.0 in /opt/conda/lib/python3.9/site-packages (from Jinja2>=3.1.0->pydbtools) (2.0.1)\n", "Requirement already satisfied: jsonschema>=3.0.0 in /opt/conda/lib/python3.9/site-packages (from mojap-metadata[arrow]<2.0.0,>=1.10.0->arrow-pd-parser>=1.3.9->pydbtools) (3.2.0)\n", "Requirement already satisfied: dataengineeringutils3>=1.4.0 in /opt/conda/lib/python3.9/site-packages (from mojap-metadata[arrow]<2.0.0,>=1.10.0->arrow-pd-parser>=1.3.9->pydbtools) (1.4.3)\n", "Requirement already satisfied: parameterized==0.7.* in /opt/conda/lib/python3.9/site-packages (from mojap-metadata[arrow]<2.0.0,>=1.10.0->arrow-pd-parser>=1.3.9->pydbtools) (0.7.5)\n", "Requirement already satisfied: PyYAML<7.0,>=6.0 in /opt/conda/lib/python3.9/site-packages (from mojap-metadata[arrow]<2.0.0,>=1.10.0->arrow-pd-parser>=1.3.9->pydbtools) (6.0.2)\n", "Requirement already satisfied: Deprecated<2.0.0,>=1.2.12 in /opt/conda/lib/python3.9/site-packages (from dataengineeringutils3>=1.4.0->mojap-metadata[arrow]<2.0.0,>=1.10.0->arrow-pd-parser>=1.3.9->pydbtools) (1.2.18)\n", "Requirement already satisfied: wrapt<2,>=1.10 in /opt/conda/lib/python3.9/site-packages (from Deprecated<2.0.0,>=1.2.12->dataengineeringutils3>=1.4.0->mojap-metadata[arrow]<2.0.0,>=1.10.0->arrow-pd-parser>=1.3.9->pydbtools) (1.17.2)\n", "Requirement already satisfied: attrs>=17.4.0 in /opt/conda/lib/python3.9/site-packages (from jsonschema>=3.0.0->mojap-metadata[arrow]<2.0.0,>=1.10.0->arrow-pd-parser>=1.3.9->pydbtools) (21.2.0)\n", "Requirement already satisfied: six>=1.11.0 in /opt/conda/lib/python3.9/site-packages (from jsonschema>=3.0.0->mojap-metadata[arrow]<2.0.0,>=1.10.0->arrow-pd-parser>=1.3.9->pydbtools) (1.16.0)\n", "Requirement already satisfied: pyrsistent>=0.14.0 in /opt/conda/lib/python3.9/site-packages (from jsonschema>=3.0.0->mojap-metadata[arrow]<2.0.0,>=1.10.0->arrow-pd-parser>=1.3.9->pydbtools) (0.17.3)\n", "Requirement already satisfied: setuptools in /opt/conda/lib/python3.9/site-packages (from jsonschema>=3.0.0->mojap-metadata[arrow]<2.0.0,>=1.10.0->arrow-pd-parser>=1.3.9->pydbtools) (58.0.4)\n", "Requirement already satisfied: pytz>=2017.3 in /opt/conda/lib/python3.9/site-packages (from pandas>=1.2->arrow-pd-parser>=1.3.9->pydbtools) (2021.1)\n", "Installing collected packages: numpy\n", " Attempting uninstall: numpy\n", " Found existing installation: numpy 1.24.3\n", " Uninstalling numpy-1.24.3:\n", " Successfully uninstalled numpy-1.24.3\n", "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", "scipy 1.7.1 requires numpy<1.23.0,>=1.16.5, but you have numpy 2.0.2 which is incompatible.\n", "numba 0.54.0 requires numpy<1.21,>=1.17, but you have numpy 2.0.2 which is incompatible.\u001b[0m\n", "Successfully installed numpy-2.0.2\n", "Collecting numpy==1.24.3\n", " Using cached numpy-1.24.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (17.3 MB)\n", "Installing collected packages: numpy\n", "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", "scipy 1.7.1 requires numpy<1.23.0,>=1.16.5, but you have numpy 1.24.3 which is incompatible.\n", "numba 0.54.0 requires numpy<1.21,>=1.17, but you have numpy 1.24.3 which is incompatible.\n", "awswrangler 3.11.0 requires numpy<2.1.0,>=1.26; python_version < \"3.10\", but you have numpy 1.24.3 which is incompatible.\u001b[0m\n", "Successfully installed numpy-1.24.3\n", "Looking in links: orce-reinstall\n", "Requirement already satisfied: pybind11>=2.12 in /opt/conda/lib/python3.9/site-packages (2.13.6)\n", "Requirement already satisfied: openpyxl in /opt/conda/lib/python3.9/site-packages (3.1.5)\n", "Requirement already satisfied: et-xmlfile in /opt/conda/lib/python3.9/site-packages (from openpyxl) (2.0.0)\n" ] } ], "source": [ "!pip install pydbtools\n", "!pip install numpy==1.24.3 --user --force-reinstall\n", "!pip install \"pybind11>=2.12\" -force-reinstall" ] }, { "cell_type": "code", "execution_count": 2, "id": "e80c4e8b-d28d-489d-959c-643b43322fe3", "metadata": {}, "outputs": [], "source": [ "import pydbtools as pydb\n", "import pandas as pd" ] }, { "cell_type": "markdown", "id": "88e715e0-7e70-4743-9e17-cbdd862e6e2b", "metadata": {}, "source": [ "## Quarterly Figures" ] }, { "cell_type": "code", "execution_count": 3, "id": "8ec8ae05-de0b-4b64-bef2-a657bb1cc53e", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | id | \n", "year | \n", "quarter | \n", "all_cases_receipts | \n", "all_cases_disposals | \n", "all_cases_opens | \n", "total_all_trial_receipts | \n", "total_all_trial_disposals | \n", "total_all_trial_opens | \n", "triable_either_way_receipts | \n", "... | \n", "indictable_only_opens | \n", "committed_for_sentence_receipts | \n", "committed_for_sentence_disposals | \n", "committed_for_sentence_opens | \n", "appeals_receipts | \n", "appeals_disposals | \n", "appeals_opens | \n", "unknown_receipts | \n", "unknown_disposals | \n", "unknown_opens | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "2f8d1c1e93f31d0765194a95718f891f | \n", "2025 | \n", "Q4 | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "... | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "
| 1 | \n", "755b7c10d16531b8a315aad797aa801c | \n", "2025 | \n", "Q3 | \n", "<NA> | \n", "1 | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "... | \n", "<NA> | \n", "<NA> | \n", "1 | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "
2 rows × 24 columns
\n", "| \n", " | id | \n", "year | \n", "all_cases_receipts | \n", "all_cases_disposals | \n", "all_cases_opens | \n", "total_all_trial_receipts | \n", "total_all_trial_disposals | \n", "total_all_trial_opens | \n", "triable_either_way_receipts | \n", "triable_either_way_disposals | \n", "... | \n", "indictable_only_opens | \n", "committed_for_sentence_receipts | \n", "committed_for_sentence_disposals | \n", "committed_for_sentence_opens | \n", "appeals_receipts | \n", "appeals_disposals | \n", "appeals_opens | \n", "unknown_receipts | \n", "unknown_disposals | \n", "unknown_opens | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "312351bff07989769097660a56395065 | \n", "2025 | \n", "14928 | \n", "14455 | \n", "75261 | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "6241 | \n", "5594 | \n", "... | \n", "21871 | \n", "5202 | \n", "5301 | \n", "11599 | \n", "571 | \n", "754 | \n", "2589 | \n", "2 | \n", "3 | \n", "6 | \n", "
| 1 | \n", "07811dc6c422334ce36a09ff5cd6fe71 | \n", "2024 | \n", "121571 | \n", "113936 | \n", "174941 | \n", "<NA> | \n", "<NA> | \n", "<NA> | \n", "49267 | \n", "43936 | \n", "... | \n", "42049 | \n", "43399 | \n", "42505 | \n", "46094 | \n", "5419 | \n", "5627 | \n", "7586 | \n", "23 | \n", "20 | \n", "23 | \n", "
2 rows × 23 columns
\n", "