import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
Female = df[(df["Gender"] == "Female")]
Male = df[(df["Gender"] == "Male")]
AgeClass = ['100+','95-99','90-94','85-89','80-84','75-79','70-74','65-69','60-64','55-59','50-54','45-49','40-44','35-39','30-34','25-29','20-24','15-19','10-14','5-9','0-4']
bar_plot = sns.barplot(x= Male, y=df['Age'], order=AgeClass)
bar_plot = sns.barplot(x= Female, y=df['Age'], order=AgeClass)
bar_plot.set(xlabel="Population (hundreds of millions)", ylabel="Age-Group", title = "Population Pyramid")
I'm trying to build a population pyramid from a pandas df using seaborn.
I got value error. Help me to fix it
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().