Tenfo este df:
NOM_MUN P8A14AN_F P8A14AN_M P15YM_AN_F P15YM_AN_M
0 Tuxtla Chico 106.0 114.0 2004.0 1277.0
1 Tuxtla Chico 15.0 17.0 243.0 117.0
2 Tuxtla Chico 0.0 0.0 10.0 15.0
3 Tuxtla Chico 2.0 5.0 36.0 39.0
4 Tuxtla Chico 4.0 4.0 49.0 25.0
E intento transformarlo con el siguiente código:
pd.wide_to_long(df_edu_tc_AN.reset_index(drop=True), stubnames=['P8A14AN','P15YM_AN'], i='NOM_MUN', j='Sexo', sep='_', suffix='\w+')
'M' y 'F' representan masculino y femenino; la idea es obtener una columna que identifique el genro y otra que identifique los prefijos ['P8A14AN','P15YM_AN'], pero este es el resultado que tengo:
ValueError: the id variables need to uniquely identify each row
Alguien sabe que estoy haciendo mal?