Skip to content

Instantly share code, notes, and snippets.

@andres-alvarado

andres-alvarado/rebe.py

Last active Mar 4, 2020
Embed
What would you like to do?
rebe = (
pd.merge( left = df,
right = rem,
how = 'inner',
left_on = ['Outs Antes De Jugada', 'Corredores Inicio De Jugada'],
right_on = ['Outs', 'Corredores']
)
.groupby( by = ['Evento'])['Expectativa']
.agg( func_or_funcs = { 'Expectativa': 'sum'
, 'N' : 'count'
}
)
.rename( columns = { 'Outs Antes De Jugada' : 'Outs'
, 'Corredores Inicio De Jugada' : 'Corredores'
}
)
.reset_index()
.assign( Expectativa = lambda x: x['Expectativa'] / x['N'] )
.drop( columns = ['N'] )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment