79408525

Date: 2025-02-03 10:46:10
Score: 2.5
Natty:
Report link

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
Reasons:
  • Has code block (-0.5):
  • Me too answer (2.5): have the same issue
  • Self-answer (0.5):
Posted by: vrghost