How does this dataset treat people with non binary gender identity?
How can you test that?
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)
]
<pandas.core.groupby.generic.DataFrameGroupBy object at 0x0000026A3F7B71F0>
gender_pop = df_2019.groupby('Gender')['Population_Estimate'].sum()
gender_pop
Gender All persons 1893667 Females 960950 Males 932717 Name: Population_Estimate, dtype: int64
gender_pop['Males']+gender_pop['Females'], gender_pop['All persons']
(1893667, 1893667)
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)
<matplotlib.axes._subplots.AxesSubplot at 0x26a4400f9d0>