Meet Dr. Ignaz Semmelweis
Created by Darío López Díaz. Work in progress..
import pandas as pd
yearly = pd.read_csv('datasets/yearly_deaths_by_clinic.csv')
print(yearly)
year births deaths clinic
0 1841 3036 237 clinic 1
1 1842 3287 518 clinic 1
2 1843 3060 274 clinic 1
3 1844 3157 260 clinic 1
4 1845 3492 241 clinic 1
5 1846 4010 459 clinic 1
6 1841 2442 86 clinic 2
7 1842 2659 202 clinic 2
8 1843 2739 164 clinic 2
9 1844 2956 68 clinic 2
10 1845 3241 66 clinic 2
11 1846 3754 105 clinic 2
# Calculate proportion of deaths per no. births
yearly['proportion_deaths']= yearly['deaths']/yearly['births']
# Extract Clinic 1 data into clinic_1 and Clinic 2 data into clinic_2
clinic_1 = yearly[yearly['clinic']=='clinic 1']
clinic_2 = yearly[yearly['clinic']=='clinic 2']
# Print out clinic_1
print(clinic_1)
year births deaths clinic proportion_deaths
0 1841 3036 237 clinic 1 0.078063
1 1842 3287 518 clinic 1 0.157591
2 1843 3060 274 clinic 1 0.089542
3 1844 3157 260 clinic 1 0.082357
4 1845 3492 241 clinic 1 0.069015
5 1846 4010 459 clinic 1 0.114464
# This makes plots appear in the notebook
%matplotlib inline
# Plot yearly proportion of deaths at the two clinics
ax = clinic_1.plot(x="year", y="proportion_deaths",
label="Clinic 1")
clinic_2.plot(x="year", y="proportion_deaths",
label="Clinic 2", ax=ax, ylabel="Proportion of Deaths",xlabel="Year")
# Read datasets/monthly_deaths.csv into monthly
monthly = pd.read_csv('datasets/monthly_deaths.csv',
parse_dates=["date"])
# Calculate proportion of deaths per no. births
monthly["proportion_deaths"] = monthly['deaths'] / monthly['births']
# Print out the first rows in monthly
monthly.loc[0]
# Plot monthly proportion of deaths
ax = monthly.plot(x="date", y="proportion_deaths")
# Date when handwashing was made mandatory
handwashing_start = pd.to_datetime('1847-06-01')
# Split monthly into before and after handwashing_start
before_washing = monthly[monthly['date'] < handwashing_start]
after_washing = monthly[monthly['date'] >= handwashing_start]
# Plot monthly proportion of deaths before and after handwashing
ax = before_washing.plot(x="date", y="proportion_deaths",
label="Before Washing")
after_washing.plot(x="date", y="proportion_deaths",
label="After Washing", ax=ax, ylabel="Proportion of Deaths",xlabel="Year")
# Difference in mean monthly proportion of deaths due to handwashing
before_proportion = before_washing['proportion_deaths']
after_proportion = after_washing['proportion_deaths']
mean_diff = after_proportion.mean() - before_proportion.mean()
mean_diff