python - pass argument to groupby and agg in pandas -


i want use agg after groupby , pass in 2 parameters, param1 , param2. tried following failed. correct way that? thanks.

def myfun(x, param1, param2):     #some calculations     return result  b = a.groupby([a.index, 'time']).agg({'salary': myfun, param1, param2}) 

use syntax:

param1=1 param2=100 a.groupby([a.index,'time'])['salary'].agg(myfun, param1, param2) 

or @ayhan suggests:

a.groupby([a.index,'time']).agg({'salary':lambda x: myfunc(x, param1, param2)}) 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -