how to sum calc values for each name and report if = 100.0000?
output:
name “a” is not 100
Advertisement
Answer
JavaScript
x
2
1
df[['name', 'calc']].groupby('name').sum()
2
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
JavaScript
1
5
1
df1=(df[['name', 'calc']].groupby('name').sum()!=100)
2
3
for name in df1.index[df1['calc']==True].to_list():
4
print(f'calc of name:{name} does not match target')
5