could you please help me understand what's wrong in the script below and how to correct it? I am just trying to add a column iterating over the file. The new column should say 'F', if the percentage of females is higher than the percentage of males. Thank you very much!
babies_df = pd.read_csv('datasets/babynames_nysiis.csv', delimiter=';')
gender=[]
for idx in range(len(babies_df)):
if babies_df['perc_female'>'perc_male']:
gender.append('F')
else:
gender.append('M')
babies_df['gender'] = gender
babies_df['perc_female'] > babies_df['perc_male']ifstatement you mistakenly comparing inside[ ]which is wrong. you should complete first column. If still error persist please add error also.