how to sum calc values for each name and report if = 100.0000?
output:
name “a” is not 100
Advertisement
Answer
df[['name', 'calc']].groupby('name').sum()
should give you the sums for each name, should return the output you were looking for
to report which names arent equal to 100, try
df1=(df[['name', 'calc']].groupby('name').sum()!=100) for name in df1.index[df1['calc']==True].to_list(): print(f'calc of name:{name} does not match target')