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