I have two dataframes. The old df and the new df, they both contain information about a candidate's name and GPA, the old df contains more gpa than the new one and for the nan values in the gpa column of the newdf, I want to assign the corresponding GPA from the old df based on the candidate's name column(The 2 df have different shape so I can't do one line command). Here's the code I tried:
for y in df_new['NAME'].unique():
for m in df_old['Name'].unique():
if y==m:
old_row=df_old.loc[df_old['Name']==m]
new_row=df_new.loc[df_new['NAME']==y]
if pd.isna(new_row['GPA'])=='True':
if pd.isna(old_row['GPA'])=='False':
new_row['GPA']=old_row['GPA']
This line "if pd.isna(new_row['GPA'])=='True':" has the error 'The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()' But I believe that new_row['GPA'] only contains one boolean value, what is going on?