#!/usr/bin/env python # coding: utf-8 # ## Question 1: Binary Computation # # How does this dataset treat people with non binary gender identity? # # How can you test that? # # In[2]: import pandas as pd # source = 'data/population.csv' source = 'https://www.opendatani.gov.uk/dataset/62e7073f-e924-4d3f-81a5-ad45b5127682/resource/67c25586-b9aa-4717-9a4b-42de21a403f2/download/parliamentary-constituencies-by-single-year-of-age-and-gender-mid-2001-to-mid-2019.csv' df = pd.read_csv(source) # `read_csv` can read from URL's or from local files aswell df_2019 = df[ (df['Mid_Year_Ending'] == 2019) ] # In[5]: gender_pop = df_2019.groupby('Gender')['Population_Estimate'].sum() gender_pop # In[6]: gender_pop['Males']+gender_pop['Females'], gender_pop['All persons'] # In[11]: pd.DataFrame.from_dict({ 'All persons': {'All':gender_pop['All persons']}, 'Gendered': {'Males':gender_pop['Males'], 'Females':gender_pop['Females']} }).T.plot.bar(stacked=True, width=1) # In[ ]: