Semmelweis and puerperal fever

This notebook is an element of the free risk-engineering.org courseware. It can be distributed under the terms of the Creative Commons Attribution-ShareAlike licence.

Author: Eric Marsden eric.marsden@risk-engineering.org.


This notebook contains an introduction to use of Python and the NumPy library to analyze statistical data.

It concerns the work of medical doctor Ignaz Semmelweis in reducing the risk of puerperal fever during childbirth in Vienna and Budapest during the mid-19th century, by requiring doctors to wash their hands using chlorinated solutions to kill bacteria (note that this was before chemist and medical researcher Louis Pasteur developed his germ theory).

In [1]:
import numpy
import pandas
import scipy.stats
import matplotlib.pyplot as plt
import seaborn as sns
%config InlineBackend.figure_formats=['svg']
numpy.set_printoptions(threshold=20)

import warnings
warnings.simplefilter(action='ignore', category=FutureWarning)
In [2]:
# Data comes from https://en.wikipedia.org/wiki/Historical_mortality_rates_of_puerperal_fever
wien = pandas.read_csv("https://risk-engineering.org/static/data/wien-fever-mortality.csv", parse_dates=['Year'])
wien.set_index('Year', inplace=True)
wien.head()
Out[2]:
Births Deaths
Year
1784-01-01 284 6
1785-01-01 899 13
1786-01-01 1151 5
1787-01-01 1407 5
1788-01-01 1425 5
In [3]:
wien["Mortality"] = 100 * wien.Deaths / wien.Births
In [4]:
wien.head()
Out[4]:
Births Deaths Mortality
Year
1784-01-01 284 6 2.112676
1785-01-01 899 13 1.446051
1786-01-01 1151 5 0.434405
1787-01-01 1407 5 0.355366
1788-01-01 1425 5 0.350877
In [5]:
plt.plot(wien.Mortality)
plt.title("Mortality from puerperal fever during childbirth")
plt.ylabel("Mortality rate (%)");

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).

There are two important dates to analyze in this time series to validate Semmelweis' hypothesis on the origin of the infections:

  • 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.

  • In 1847, Semmelweis managed to convince doctors always to wash their hands with a chlorinated solution between autopsy work and work with patients.

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.

In [6]:
period1 = wien.query('Year < 1823')
period1.Mortality.mean()
Out[6]:
1.1659516507026884
In [7]:
period2 = wien.query('1823 < Year < 1847')
period2.Mortality.mean()
Out[7]:
6.8668833843503965
In [8]:
period3 = wien.query('1847 < Year')
period3.Mortality.mean()
Out[8]:
1.9676219516106366
In [9]:
wien.loc[:'1832', 'Period'] = 'Period 1'
wien.loc['1833':'1847', 'Period'] = 'Period 2'
wien.loc['1848':, 'Period'] = 'Period 3'
In [10]:
sns.violinplot(data=wien, x="Period", y="Mortality", ci=95);

This result is indeed quite convincing, in particular the marked reduction in infection rate during period 3, when doctors were following the risk reduction measure.