Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ID score
- 100 1
- 100 2
- 102 6
- 102 8
- 102 12
- 103 4
- 103 7
- ID score result
- 100 1 NaN*
- 100 2 1
- 102 6 NaN
- 102 8 2
- 102 12 4
- 103 4 NaN
- 103 7 3
- df['result'] = df.groupby('ID')['score'].transform('diff')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement