Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from io import StringIO
- import pandas as pd
- DATA="""id,target,valores
- 1,100,20
- 1,100,30
- 1,100,50
- 1,100,15
- 1,100,45
- 1,100,60
- 2,150,75
- 2,150,75
- 2,150,100
- 3,1500,900
- 3,1500,500
- 3,1500,600
- 3,1500,1000
- 3,1500,750
- 3,1500,200
- 3,1500,300
- 3,1500,10
- 3,1500,30
- 3,1500,50
- """
- df = pd.read_csv(StringIO(DATA))
- suma = df.groupby(['id','target'], as_index=False)['valores'].sum()
- print(suma)
- suma.query('valores-1 < target < valores+1')
Add Comment
Please, Sign In to add comment