|
1 | 1 | from __future__ import annotations
|
2 |
| -from typing import Sequence, Union, TYPE_CHECKING, NoReturn, Mapping |
| 2 | + |
| 3 | +from typing import Literal, Mapping, Sequence, Union, TYPE_CHECKING, NoReturn |
| 4 | + |
3 | 5 |
|
4 | 6 | if TYPE_CHECKING:
|
5 | 7 | from .column_object import Column
|
@@ -260,6 +262,48 @@ def concat(self, other: Sequence[DataFrame]) -> DataFrame:
|
260 | 262 | -------
|
261 | 263 | DataFrame
|
262 | 264 | """
|
| 265 | + ... |
| 266 | + |
| 267 | + def sorted_indices( |
| 268 | + self, |
| 269 | + keys: Sequence[str], |
| 270 | + *, |
| 271 | + ascending: Sequence[bool] | bool = True, |
| 272 | + nulls_position: Literal['first', 'last'] = 'last', |
| 273 | + ) -> Column[int]: |
| 274 | + """ |
| 275 | + Return row numbers which would sort according to given columns. |
| 276 | +
|
| 277 | + If you need to sort the DataFrame, you can simply do:: |
| 278 | +
|
| 279 | + df.get_rows(df.sorted_indices(keys)) |
| 280 | +
|
| 281 | + Parameters |
| 282 | + ---------- |
| 283 | + keys : Sequence[str] |
| 284 | + Names of columns to sort by. |
| 285 | + ascending : Sequence[bool] or bool |
| 286 | + If `True`, sort by all keys in ascending order. |
| 287 | + If `False`, sort by all keys in descending order. |
| 288 | + If a sequence, it must be the same length as `keys`, |
| 289 | + and determines the direction with which to use each |
| 290 | + key to sort by. |
| 291 | + nulls_position : {'first', 'last'} |
| 292 | + Whether null values should be placed at the beginning |
| 293 | + or at the end of the result. |
| 294 | + Note that the position of NaNs is unspecified and may |
| 295 | + vary based on the implementation. |
| 296 | +
|
| 297 | + Returns |
| 298 | + ------- |
| 299 | + Column[int] |
| 300 | + |
| 301 | + Raises |
| 302 | + ------ |
| 303 | + ValueError |
| 304 | + If `keys` and `ascending` are sequences of different lengths. |
| 305 | + """ |
| 306 | + ... |
263 | 307 |
|
264 | 308 | def __eq__(self, other: DataFrame | Scalar) -> DataFrame:
|
265 | 309 | """
|
|
0 commit comments