I have a dataframe looks like this:
????????????JOINED_CO GENDER ???EXEC_FULLNAME ?GVKEY ?YEAR ?CONAME ?BECAMECEO ?REJOIN ??LEFTOFC ???LEFTCO ?RELEFT ???REASON ?PAGE
CO_PER_ROL ????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
5622 ?????????????NaN ??MALE ??Ira A. Eichner ??1004 ?1992 ?AAR CORP ??19550101 ????NaN ?19961001 ?19990531 ????NaN ?RESIGNED ???79
5622 ?????????????NaN ??MALE ??Ira A. Eichner ??1004 ?1993 ?AAR CORP ??19550101 ????NaN ?19961001 ?19990531 ????NaN ?RESIGNED ???79
5622 ?????????????NaN ??MALE ??Ira A. Eichner ??1004 ?1994 ?AAR CORP ??19550101 ????NaN ?19961001 ?19990531 ????NaN ?RESIGNED ???79
5622 ?????????????NaN ??MALE ??Ira A. Eichner ??1004 ?1995 ?AAR CORP ??19550101 ????NaN ?19961001 ?19990531 ????NaN ?RESIGNED ???79
5622 ?????????????NaN ??MALE ??Ira A. Eichner ??1004 ?1996 ?AAR CORP ??19550101 ????NaN ?19961001 ?19990531 ????NaN ?RESIGNED ???79
5622 ?????????????NaN ??MALE ??Ira A. Eichner ??1004 ?1997 ?AAR CORP ??19550101 ????NaN ?19961001 ?19990531 ????NaN ?RESIGNED ???79
5622 ?????????????NaN ??MALE ??Ira A. Eichner ??1004 ?1998 ?AAR CORP ??19550101 ????NaN ?19961001 ?19990531 ????NaN ?RESIGNED ???79
5623 ?????????????NaN ??MALE ?David P. Storch ??1004 ?1992 ?AAR CORP ??19961009 ????NaN ??????NaN ??????NaN ????NaN ??????NaN ???57
5623 ?????????????NaN ??MALE ?David P. Storch ??1004 ?1993 ?AAR CORP ??19961009 ????NaN ??????NaN ??????NaN ????NaN ??????NaN ???57
5623 ?????????????NaN ??MALE ?David P. Storch ??1004 ?1994 ?AAR CORP ??19961009 ????NaN ??????NaN ??????NaN ????NaN ??????NaN ???57
5623 ?????????????NaN ??MALE ?David P. Storch ??1004 ?1995 ?AAR CORP ??19961009 ????NaN ??????NaN ??????NaN ????NaN ??????NaN ???57
5623 ?????????????NaN ??MALE ?David P. Storch ??1004 ?1996 ?AAR CORP ??19961009 ????NaN ??????NaN ??????NaN ????NaN ??????NaN ???57
For the YEAR value, I like to add year columns (1993,1994...,2009) to the original dataframe, If the value in YEAR is 1992, then the value in the 1992 column should be 1 otherwise 0.
I used a very stupid for loop, but it seems to run forever as I have a large dataset.
Could anyone help me with it, thanks a lot!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…