In [21]:
dfm=pd.melt(frame=df,id_vars=['country','year'])
In [22]:
dfm['sex']=dfm.variable.str[0]
df
Out[22]:
country year m014 m1524
0 AD 2000 0 0
1 AE 2000 2 4
2 AF 2000 52 228