As mentioned in my comment, using the .loc
property will get you there.
This returns a boolean Series on the gender
column and creates a new column matching the search criteria.
df['M'] = df.loc[df['gender'] == 'E', 'gender']
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…