I have a dataframe which has the following data:
Age A
5 True
5 True
10 False
15 False
15 True
20 False
25 True
How can I make a bar chart plot which has the values of the total number of rows in Age? So for example, 7 as the Y axis and the age as the X axis, with each Age having a True/False bar plot.
I would like something like this, however instead of it saying gender F/M, it does True/False, for each Age range:
CodePudding user response:
CodePudding user response:
Probably your want something like this:
count_df = df.groupby("Age").count()
plt.barh(count_df.index, count_df.A, label="False")
sum_df = df.groupby("Age").sum()
plt.barh(sum_df.index, sum_df.A, label="True")
plt.legend()
let me know if I get what you want or i misunderstood your problem.