I have a dataset where I have age as a continuous variable and I want to county the number of occurrences of 1's and 0's in "Mental Health" for a number of age group ranges, e.g. 18-25, 26-33, and so on.
A sample code is as below:
df = pd.DataFrame([[18, 1], [45, 1], [56, 0], [26, 0], [35, 1]], columns=['Age', 'Mental_Health'])
What is the easiest way to do this? I don't really want to convert the age into a range if I can avoid it, if I have to I will but I'm ideally looking for something which comes out with 18-25 suffering = 24, not suffering = 21, and so on for all age ranges.
What is the easiest way of doing this?