Figured it out trying to write this, but if anyone have the same issue, the key is in the group.index, and using .loc not .iloc
for name, group in group_by_class:
mask = group["child"].notna()
parent_name = group[mask]["name"].values[0]
print(group.index)
df.loc[group.index, 'parents_in_group'] = parent_name
df