Description
Originally posted to https://groups.google.com/forum/#!topic/xarray/wsxeiIPLhgM
DataArray.argsort()
appears to simply wrap the result of DataArray.values.argsort()
in a same-shape DataArray
. This is semantically nonsensical. If anything the index on the resulting argsort()
values should simply be range(len(da))
, but that adds little to the underlying numpy structure. And there's not much reason to have da.argsort()
simply return the (raw) result of da.values.argsort()
. So really DataArray.argsort()
should simply be deleted.
On the other hand a new function DataArray.rank()
that wraps da.values.argsort().argsort()
(note repeated call to ndarray.argsort()
) in the structure of the original DataArray
would make sense, and perhaps even be useful... (Note that I'm not claiming that .argsort().argsort()
is the fastest way to calculate this, but it's probably good enough, at least for an initial implementation.)