{ "cells": [ { "cell_type": "markdown", "id": "35cc9e67", "metadata": {}, "source": [ "# Subdividing and categorising data\n", "\n", "Continuous data is often divided into domains or otherwise grouped for analysis." ] }, { "cell_type": "markdown", "id": "625f4a8b", "metadata": {}, "source": [ "Suppose you have data on a group of people in a study that you want to divide into discrete age groups. For this, we generate a dataframe with 250 entries between `0` and `99`:" ] }, { "cell_type": "code", "execution_count": 1, "id": "fe17e156", "metadata": { "execution": { "iopub.execute_input": "2026-05-21T13:00:07.250228Z", "iopub.status.busy": "2026-05-21T13:00:07.249985Z", "iopub.status.idle": "2026-05-21T13:00:07.574238Z", "shell.execute_reply": "2026-05-21T13:00:07.573964Z", "shell.execute_reply.started": "2026-05-21T13:00:07.250209Z" } }, "outputs": [ { "data": { "text/html": [ "
| \n", " | Age | \n", "
|---|---|
| 0 | \n", "40 | \n", "
| 1 | \n", "33 | \n", "
| 2 | \n", "8 | \n", "
| 3 | \n", "90 | \n", "
| 4 | \n", "98 | \n", "
| ... | \n", "... | \n", "
| 245 | \n", "59 | \n", "
| 246 | \n", "46 | \n", "
| 247 | \n", "88 | \n", "
| 248 | \n", "10 | \n", "
| 249 | \n", "37 | \n", "
250 rows × 1 columns
\n", "| \n", " | Age | \n", "Age group | \n", "
|---|---|---|
| 0 | \n", "40 | \n", "40 - 49 | \n", "
| 1 | \n", "33 | \n", "30 - 39 | \n", "
| 2 | \n", "8 | \n", "0 - 9 | \n", "
| 3 | \n", "90 | \n", "90 - 99 | \n", "
| 4 | \n", "98 | \n", "90 - 99 | \n", "
| ... | \n", "... | \n", "... | \n", "
| 245 | \n", "59 | \n", "50 - 59 | \n", "
| 246 | \n", "46 | \n", "40 - 49 | \n", "
| 247 | \n", "88 | \n", "80 - 89 | \n", "
| 248 | \n", "10 | \n", "10 - 19 | \n", "
| 249 | \n", "37 | \n", "30 - 39 | \n", "
250 rows × 2 columns
\n", "