-2

how to sum calc values for each name and report if = 100.0000?

df example

output:

name "a" is not 100

output df

  • please don't send images of things that would be necessary on the process of recreating the issue. – XxJames07- Aug 03 '22 at 18:01
  • 1
    Does this answer your question? [How do I Pandas group-by to get sum?](https://stackoverflow.com/questions/39922986/how-do-i-pandas-group-by-to-get-sum) – srinath Aug 03 '22 at 18:01

1 Answers1

0
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')