{ "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": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
birthsdeaths
year
1784-01-012846
1785-01-0189913
1786-01-0111515
1787-01-0114075
1788-01-0114255
\n", "
" ], "text/plain": [ " births deaths\n", "year \n", "1784-01-01 284 6\n", "1785-01-01 899 13\n", "1786-01-01 1151 5\n", "1787-01-01 1407 5\n", "1788-01-01 1425 5" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Data comes from https://en.wikipedia.org/wiki/Historical_mortality_rates_of_puerperal_fever\n", "wien = pandas.read_csv(\"https://risk-engineering.org/static/data/wien-fever-mortality.csv\", parse_dates=[\"year\"])\n", "wien.set_index(\"year\", inplace=True)\n", "wien.head()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "wien[\"mortality\"] = 100 * wien.deaths / wien.births" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 2023-07-06T15:26:51.996973\n", " image/svg+xml\n", " \n", " \n", " Matplotlib v3.7.2, https://matplotlib.org/\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n" ], "text/plain": [ "
" ] }, "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
births1deaths1births2deaths2
year
1833-01-0137371973538
1834-01-0126572051744150
1835-01-012573143168284
1836-01-0126772001670131
1837-01-0127652511784124
\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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
births1deaths1births2deaths2mortality1mortality2
year
1833-01-01373719735385.2716082.266289
1834-01-01265720517441507.7154698.600917
1835-01-0125731431682845.5577154.994055
1836-01-01267720016701317.4710507.844311
1837-01-01276525117841249.0777586.950673
\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", " \n", " \n", " \n", " \n", " 2023-07-06T15:26:52.359166\n", " image/svg+xml\n", " \n", " \n", " Matplotlib v3.7.2, https://matplotlib.org/\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "past = clinics.query(\"year < 1847\")\n", "plt.figure(figsize=(10,3))\n", "plt.plot(past.mortality1, label=\"Clinic 1\")\n", "plt.plot(past.mortality2, label=\"Clinic 2\")\n", "plt.legend()\n", "plt.title(\"Mortality from puerperal fever during childbirth\")\n", "plt.ylabel(\"Mortality rate (%)\");" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Dr Semmelweis suspected that the higher death rates in clinic 1 were due to it being staffed by medical students who were also studying autopsy by examining corpses.\n", "\n", "In 1847, Semmelweis managed to convince doctors always to wash their hands with a chlorinated solution between autopsy work and work with patients. This was an unorthodox suggestion at the time (note that this was before chemist and medical researcher Louis Pasteur developed his germ theory). We can examine the effect that this preventive measure had on mortality rates: " ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "scrolled": true }, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 2023-07-06T15:26:52.537533\n", " image/svg+xml\n", " \n", " \n", " Matplotlib v3.7.2, https://matplotlib.org/\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import datetime\n", "\n", "plt.figure(figsize=(10,3))\n", "plt.plot(clinics.mortality1, label=\"Clinic 1\")\n", "plt.plot(clinics.mortality2, label=\"Clinic 2\")\n", "plt.axvline(datetime.date(1841, 1, 1), color=\"red\")\n", "plt.axvline(datetime.date(1847, 5, 1), color=\"red\")\n", "plt.title(\"Mortality from puerperal fever during childbirth\")\n", "plt.legend()\n", "plt.ylabel(\"Mortality rate (%)\");" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This graph shows that the difference between the two clinics was strongly reduced following the introduction of handwashing. \n", "\n", "There was significant resistance to the implementation of techniques suggested by Semmelweis. Some doctors, for instance, were offended at the suggestion that they should wash their hands, feeling that their social status as gentlemen was inconsistent with the idea that their hands could be unclean (and with the “ridiculous” notion that as doctors, they could be responsible for the transmission of disease 😱). \n", "\n", "There are two important dates to analyze in this time series to validate Semmelweis’ hypothesis on the origin of the infections:\n", "\n", "- In 1823, 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. \n", "\n", "- In 1847, Semmelweis managed to convince doctors always to wash their hands with a chlorinated solution between autopsy work and work with patients.\n", "\n", "We want to compare the death rate attributed to puerperal fever in the three periods delimited by these two dates, to determine whether the rate increased after the introduction of anatomy lessons and decreased after handwashing was implemented, as is suggested by the graph above." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.1659516507026884" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "period1 = wien.query(\"year < 1823\")\n", "period1.mortality.mean()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "6.817302050585868" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "period2 = wien.query(\"1823 <= year <= 1847\")\n", "period2.mortality.mean()" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.9676219516106366" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "period3 = wien.query(\"1847 < year\")\n", "period3.mortality.mean()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [], "source": [ "wien.loc[:\"1832\", \"period\"] = \"Period 1\"\n", "wien.loc[\"1833\":\"1847\", \"period\"] = \"Period 2\"\n", "wien.loc[\"1848\":, \"period\"] = \"Period 3\"" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 2023-07-06T15:26:52.802871\n", " image/svg+xml\n", " \n", " \n", " Matplotlib v3.7.2, https://matplotlib.org/\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n" ], "text/plain": [ "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "sns.violinplot(data=wien, x=\"period\", y=\"mortality\", ci=95);" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This result is indeed quite convincing, in particular the marked reduction in infection rate moving from period 2 to period 3, when doctors were following the risk reduction measure." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Epilogue\n", "\n", "As the French philosopher Voltaire wrote, “It is dangerous to be right in matters on which the established authorities are wrong”. Despite the statistical evidence of the usefulness of the handwashing precautions he put in place, Semmelweis was unpopular with the medical establishment, and in 1849 was unable to renew his position in the maternity, or in other hospitals in Vienna. He ended up returning to Budapest, with significant frustration. His handwashing theory was criticized in numerous medical journals and public lectures. Semmelweis ended up having a nervous breakdown, being committed to a mental institution and dying from an infection at age 47 after an encounter with a guard. " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "anaconda-cloud": null, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.4" }, "name": "basic-statistics.ipynb" }, "nbformat": 4, "nbformat_minor": 1 }