Question on cost per head plot
Closed this issue · 1 comments
florisvanlaarhoven commented
Hi,
I have used the following code:
range_age = range(18)
plt.plot(range_age, costs_per_sex_age[costs_per_sex_age.sex == 'M'].costs_per_head,label='Male')
plt.plot(range_age, costs_per_sex_age[costs_per_sex_age.sex == 'F'].costs_per_head,label='Female')
plt.xlabel('age')
plt.ylabel('Cost per head')
plt.show()
However, I know the range_age is wrong, but I don't know how to get the right values on the x-axis, because my dataframe is not ordered by age, but by category of age. E.g.: 0 t/m 4, 5 t/m 8 etc.
So how should I solve this?
janboone commented
I think this is related to the previous point. In the correct dataset the variable age corresponds to 0,1,2,... and hence maps to range(90) statement as you are using.