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

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

```
# 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()
```

```
wien["Mortality"] = 100 * wien.Deaths / wien.Births
```

```
wien.head()
```

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

```
period1 = wien.query('Year < 1823')
period1.Mortality.mean()
```

```
period2 = wien.query('1823 < Year < 1847')
period2.Mortality.mean()
```

```
period3 = wien.query('1847 < Year')
period3.Mortality.mean()
```

```
wien.loc[:'1832', 'Period'] = 'Period 1'
wien.loc['1833':'1847', 'Period'] = 'Period 2'
wien.loc['1848':, 'Period'] = 'Period 3'
```

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