In [2]:
import pandas as pd
from bokeh.charts import Bar
from bokeh.plotting import show, VBox, output_file, output_notebook
In [3]:
df = pd.read_csv("Cambridge engineering acceptance stats.csv", index_col="Year")
df = df.sort_index()
In [4]:
df_absolute = pd.DataFrame()
df_absolute['Female'] = df.F
df_absolute['Male'] = df.M
df_percent = pd.DataFrame()
df_percent['Female'] = 100 * df.F / ( df.M + df.F )
df_percent['Male'] = 100 * df.M / ( df.M + df.F )
In [5]:
width = 800
height = 600
absolute = Bar(
df_absolute, width=width, height=height, tools="save, resize", legend=True, stacked=True,
title="# Cambridge Engineering Undergraduates", ylabel = "Number of students", xlabel="Year",
palette=["#fc8d62", "#8da0cb"]
)
percent = Bar(
df_percent, width=width, height=height, tools="save, resize", legend=True, stacked=True,
title="% Cambridge Engineering Undergraduates", ylabel = "% of students admitted", xlabel="Year",
palette=["#fc8d62", "#8da0cb"]
)
output_file("cambridge_engineering_admissions_by_gender.html")
show(VBox(absolute, percent))
In [6]:
output_notebook()
show(VBox(absolute, percent))