# xarray.Dataset.rank

#### Dataset.rank(dim, , pct=False, keep_attrs=None)[[source]](https://github.com/pydata/xarray/blob/main/xarray/core/dataset.py#L8557-L8611)

Ranks the data.

Equal values are assigned a rank that is the average of the ranks that
would have been otherwise assigned to all of the values within
that set.
Ranks begin at 1, not 0. If pct is True, computes percentage ranks.

NaNs in the input array are returned as NaNs.

The bottleneck library is required.

* **Parameters:**
  * **dim** (`Hashable`) – Dimension over which to compute rank.
  * **pct** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool), *default*: [`False`](https://docs.python.org/3/builtins/constants.html#False)) – If True, compute percentage ranks, otherwise compute integer ranks.
  * **keep_attrs** ([`bool`](https://docs.python.org/3/builtins/functions.html#bool) or [`None`](https://docs.python.org/3/builtins/constants.html#None), *optional*) – If True, the dataset’s attributes (attrs) will be copied from
    the original object to the new one.  If False, the new
    object will be returned without attributes.
* **Returns:**
  **ranked** ([`Dataset`](xarray.Dataset.html.md#xarray.Dataset)) – Variables that do not depend on dim are dropped.
