How to create a df that gets sum of columns based on a groupby column?
This question is more appropriate at Stackoverflow since it is more of a programming question.

However, I think you almost got it working. Just remove gender from your groupby:

df_new = df.groupby(['country', 'year', 'measure'])['value0', ... 'value12'].apply(lambda x : x.astype(float).sum())