You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's the proposal: allow lambdas on methods where the primary argument is a single xarray object, and interpret lambas as though they'd be supplied in a pipe method followed by the current method.
Taking the example from the linked issue:
In [1]: importxarrayasxrIn [2]: importnumpyasnpIn [3]: da=xr.DataArray(np.random.rand(2,3))
In [4]: da.where(da>0.5)
Out[4]:
<xarray.DataArray (dim_0: 2, dim_1: 3)>array([[ nan, 0.71442406, nan],
[0.55748705, nan, nan]])
Dimensionswithoutcoordinates: dim_0, dim_1# this should be equivalent (currently not valid)In [5]: da.where(lambdax: x>0.5)
# the longer version (currently works)In [5]: da.pipe(lambdax: x.where(x>0.5))
Others I miss from pandas: assign, and loc.
I haven't gone through the list though assume there are others; we don't have to agree 100% on the list before starting with the most obvious ones, assuming we're in agreement with the principle.
The text was updated successfully, but these errors were encountered:
Branching from #3770
Here's the proposal: allow lambdas on methods where the primary argument is a single xarray object, and interpret lambas as though they'd be supplied in a
pipe
method followed by the current method.Taking the example from the linked issue:
Others I miss from pandas:
assign
, andloc
.I haven't gone through the list though assume there are others; we don't have to agree 100% on the list before starting with the most obvious ones, assuming we're in agreement with the principle.
The text was updated successfully, but these errors were encountered: