Guest User

Untitled

a guest
Feb 21st, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. from io import StringIO
  2. import pandas as pd
  3.  
  4.  
  5. DATA="""id,target,valores
  6. 1,100,20
  7. 1,100,30
  8. 1,100,50
  9. 1,100,15
  10. 1,100,45
  11. 1,100,60
  12. 2,150,75
  13. 2,150,75
  14. 2,150,100
  15. 3,1500,900
  16. 3,1500,500
  17. 3,1500,600
  18. 3,1500,1000
  19. 3,1500,750
  20. 3,1500,200
  21. 3,1500,300
  22. 3,1500,10
  23. 3,1500,30
  24. 3,1500,50
  25. """
  26.  
  27. df = pd.read_csv(StringIO(DATA))
  28. suma = df.groupby(['id','target'], as_index=False)['valores'].sum()
  29. print(suma)
  30. suma.query('valores-1 < target < valores+1')
Add Comment
Please, Sign In to add comment