First, group by Family
and then transform amount and then you can directly divide Amount
by the new column.
df['Total_Fam'] = df.groupby('Family')['Amount'].transform(np.sum)
df['Id_Percent'] = df['Amount']/df['Total_Fam']
df
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…