Skip to content

add DataFrame.sorted_indices #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 27, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion spec/API_specification/dataframe_api/dataframe_object.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import annotations
from typing import Sequence, Union, TYPE_CHECKING, NoReturn
from typing import Literal, Mapping, Sequence, Union, TYPE_CHECKING, NoReturn

if TYPE_CHECKING:
from .column_object import Column
Expand Down Expand Up @@ -214,6 +214,43 @@ def get_column_names(self) -> Sequence[str]:
"""
...

def sort(
self,
keys: Sequence[str],
*,
ascending: Sequence[bool] | bool = True,
nulls_position: Literal['first', 'last'] = 'last',
) -> DataFrame:
"""
Sort rows according to given columns.

Parameters
----------
keys : Sequence[str]
Names of columns to sort by.
ascending : Sequence[bool] or bool
If `True`, sort by all keys in ascending order.
If `False`, sort by all keys in descending order.
If a sequence, it must be the same length as `keys`,
and determines the direction with which to use each
key to sort by.
nulls_position : {'first', 'last'}
Whether null values should be placed at the beginning
or at the end of the result.
Note that the position of NaNs is unspecified and may
vary based on the implementation.

Returns
-------
DataFrame

Raises
------
ValueError
If `keys` and `ascending` are sequences of different lengths.
"""
...

def __eq__(self, other: DataFrame | Scalar) -> DataFrame:
"""
Compare for equality.
Expand Down