I am working on a mock census data and want to use my data frame to take the values of 'Male' and 'Female' from the Gender Column and plot them against their ages, which in itself is a different column. I have tried multiple different ways and cannot get this to plot at all. The data has been cleaned in the dataframe and I have also attempted to split this data with a numpy array, although I know that there is a way of doing this just manipulating the dataframe, though I don't know how.
Attempted code for pyramid
*pop_age = df.T
pop_age.reset_index(inplace=True)
pop_age.columns = ['Age', 'Female', 'Male']
f, ax = plt.subplots(figsize=(10,20))
age_plot = sns.barplot(x='Male', y='Age', data=pop_age, lw=0)
age_plot = sns.barplot(x='Female', y='Age', data=pop_age, lw=0)
age_plot.set(xlabel='Population Count', ylabel='Age', title='Population Age Pyramid')*
Numpy Array splitting the data
men=[]
women=[]
for i in range(len(data2)):
if data2[i][7] == 'Male':
a=data2[i]
men.append(a)
elif data2[i][7] == 'Female' or 'Fe male':
b=data2[i]
woman.append(b)
Any help would be appreciated. :)