{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"source": [
"# Semmelweis and puerperal fever "
]
},
{
"cell_type": "markdown",
"metadata": {
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"source": [
"\n",
"\n",
"This notebook is an element of the free [risk-engineering.org courseware](https://risk-engineering.org/). It can be distributed under the terms of the [Creative Commons Attribution-ShareAlike licence](https://creativecommons.org/licenses/by-sa/4.0/). \n",
"\n",
"Author: Eric Marsden . \n",
"\n",
"---\n",
"\n",
"This notebook contains an introduction to use of Python and the NumPy library to analyze statistical data. \n",
"\n",
"It concerns the work of medical doctor [Ignaz Semmelweis](https://en.wikipedia.org/wiki/Ignaz_Semmelweis) in reducing the risk of puerperal fever during childbirth in Vienna and Budapest during the mid-19th century. Semmelweis collected and analyzed historical data on deaths in his clinic and established a theory of what was contributing to deaths of mothers as well as a risk reduction measure. Semmelweis required doctors to wash their hands using chlorinated solutions before examining patients, which reduced mortality rates in the hospitals where the preventive measure was applied. "
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"autoscroll": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [],
"source": [
"import numpy\n",
"import pandas\n",
"import scipy.stats\n",
"import matplotlib.pyplot as plt\n",
"import seaborn as sns\n",
"%config InlineBackend.figure_formats=[\"svg\"]\n",
"plt.style.use(\"bmh\")\n",
"\n",
"import warnings\n",
"warnings.simplefilter(action=\"ignore\", category=FutureWarning)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Dr Semmelweis, a Hungarian doctor who started working at Vienna General Hospital’s maternity clinic in 1846, was concerned by the high mortality rates due to childbed fever, which in some hospitals was as high as 40% of admitted mothers. He collected and analyzed the data available concerning death rates each month in different hospitals."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.figure(figsize=(10,3))\n",
"plt.plot(wien.mortality)\n",
"plt.title(\"Mortality from puerperal fever during childbirth\")\n",
"plt.ylabel(\"Mortality rate (%)\");"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Dr Semmelweis noticed that the mortality rate started increasing around 1823, when the clinic started lessons on pathological anatomy. Doctors would take classes on cadavers in the morgue, then might deliver a baby or examine a patient, possibly with pieces of contaminated flesh remaining on their hands. One of Semmelweis’ colleagues suffered an accidental cut from a scalpel during a dissection and quickly died, with the same types of symptoms as mothers with childbed fever saw. From these observations, Semmelweis developed a suspicion that something present on the corpses, and spread by the hands of the doctors, was causing the childbed fever.\n",
"\n",
"Dr Semmelweis looked for further evidence supporting his hypothesis. There were two maternity clinics at his hospital in Vienna, managed in different ways. He analyzed the death rates in these two clinics. "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"autoscroll": false,
"ein.hycell": false,
"ein.tags": "worksheet-0",
"slideshow": {
"slide_type": "-"
}
},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
"
\n",
"
\n",
"
births1
\n",
"
deaths1
\n",
"
births2
\n",
"
deaths2
\n",
"
\n",
"
\n",
"
year
\n",
"
\n",
"
\n",
"
\n",
"
\n",
"
\n",
" \n",
" \n",
"
\n",
"
1833-01-01
\n",
"
3737
\n",
"
197
\n",
"
353
\n",
"
8
\n",
"
\n",
"
\n",
"
1834-01-01
\n",
"
2657
\n",
"
205
\n",
"
1744
\n",
"
150
\n",
"
\n",
"
\n",
"
1835-01-01
\n",
"
2573
\n",
"
143
\n",
"
1682
\n",
"
84
\n",
"
\n",
"
\n",
"
1836-01-01
\n",
"
2677
\n",
"
200
\n",
"
1670
\n",
"
131
\n",
"
\n",
"
\n",
"
1837-01-01
\n",
"
2765
\n",
"
251
\n",
"
1784
\n",
"
124
\n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" births1 deaths1 births2 deaths2\n",
"year \n",
"1833-01-01 3737 197 353 8\n",
"1834-01-01 2657 205 1744 150\n",
"1835-01-01 2573 143 1682 84\n",
"1836-01-01 2677 200 1670 131\n",
"1837-01-01 2765 251 1784 124"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Data comes from https://en.wikipedia.org/wiki/Historical_mortality_rates_of_puerperal_fever\n",
"clinics = pandas.read_csv(\"https://risk-engineering.org/static/data/wien-fever-mortality-per-clinic.csv\", parse_dates=[\"year\"])\n",
"clinics.set_index(\"year\", inplace=True)\n",
"clinics.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Column `births1` indicates the number of births in clinic 1 during that year, and `deaths1` the number of deaths. From these, we can calculate the mortality rate in each clinic. "
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"# mortality in clinic 1 and in clinic 2\n",
"clinics[\"mortality1\"] = 100 * clinics.deaths1 / clinics.births1\n",
"clinics[\"mortality2\"] = 100 * clinics.deaths2 / clinics.births2"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
"
\n",
"
\n",
"
births1
\n",
"
deaths1
\n",
"
births2
\n",
"
deaths2
\n",
"
mortality1
\n",
"
mortality2
\n",
"
\n",
"
\n",
"
year
\n",
"
\n",
"
\n",
"
\n",
"
\n",
"
\n",
"
\n",
"
\n",
" \n",
" \n",
"
\n",
"
1833-01-01
\n",
"
3737
\n",
"
197
\n",
"
353
\n",
"
8
\n",
"
5.271608
\n",
"
2.266289
\n",
"
\n",
"
\n",
"
1834-01-01
\n",
"
2657
\n",
"
205
\n",
"
1744
\n",
"
150
\n",
"
7.715469
\n",
"
8.600917
\n",
"
\n",
"
\n",
"
1835-01-01
\n",
"
2573
\n",
"
143
\n",
"
1682
\n",
"
84
\n",
"
5.557715
\n",
"
4.994055
\n",
"
\n",
"
\n",
"
1836-01-01
\n",
"
2677
\n",
"
200
\n",
"
1670
\n",
"
131
\n",
"
7.471050
\n",
"
7.844311
\n",
"
\n",
"
\n",
"
1837-01-01
\n",
"
2765
\n",
"
251
\n",
"
1784
\n",
"
124
\n",
"
9.077758
\n",
"
6.950673
\n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" births1 deaths1 births2 deaths2 mortality1 mortality2\n",
"year \n",
"1833-01-01 3737 197 353 8 5.271608 2.266289\n",
"1834-01-01 2657 205 1744 150 7.715469 8.600917\n",
"1835-01-01 2573 143 1682 84 5.557715 4.994055\n",
"1836-01-01 2677 200 1670 131 7.471050 7.844311\n",
"1837-01-01 2765 251 1784 124 9.077758 6.950673"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"clinics.head()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Dr Semmelweis arrived in 1846, and spent a year analyzing the data. He noticed that the death rates in the past years were much higher in one clinic than the other one. Furthermore, the difference between the two clinics started around 1841, when clinic 2 started being run only by midwives. "
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n",
"\n"
],
"text/plain": [
"