df['color'] = ( df['color'] .fillna( df.groupby('toy')['color'] .transform(lambda x: x.mode()[0]) ) )