python xarray - groupby.apply method taking more than one arguments -


in xarray document, groupby.apply method can apply function different groups. in documentation,

in [11]: def standardize(x):    ....:     return (x - x.mean()) / x.std()    ....:   in [12]: arr.groupby('letters').apply(standardize)  

however, how can put argument standardize function? i.e.

 def standardize(x, y):    ....:     return (x - x.mean()) / x.std() + y.sum() arr.groupby('letters').apply(standardize(x, y))?? 

it obvious not right. now, there no way call apply method.

to apply operation on multiple variables @ once, put multiple dataarray objects single xarray.dataset, e.g.,

# foo , bar xarray.dataarray objects ds = xarray.dataset({'x': foo, 'y': bar})  def standardize(ds):     return (ds.x - ds.x.mean()) / ds.x.std() + ds.y.sum()  ds.groupby('letters').apply(standardize) 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -