Skip to content

Instantly share code, notes, and snippets.

@jrovegno
Created February 8, 2018 21:32
Show Gist options
  • Save jrovegno/e1eb651b58a4338bfe9eff203d6c1e1c to your computer and use it in GitHub Desktop.
Save jrovegno/e1eb651b58a4338bfe9eff203d6c1e1c to your computer and use it in GitHub Desktop.
Pregunta de stvzito en python-es
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')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment