Skip to content

Allow for positional arguments instead of str | list[str] #284

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 2 commits into from
Oct 24, 2023
Merged
Changes from all 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
32 changes: 15 additions & 17 deletions spec/API_specification/dataframe_api/dataframe_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ def shape(self) -> tuple[int, int]:
Return number of rows and number of columns.
"""

def group_by(self, keys: str | list[str], /) -> GroupBy:
def group_by(self, *keys: str) -> GroupBy:
"""
Group the DataFrame by the given columns.

Parameters
----------
keys : str | list[str]
*keys : str

Returns
-------
Expand Down Expand Up @@ -179,7 +179,7 @@ def filter(self, mask: Column) -> DataFrame:
"""
...

def assign(self, columns: Column | Sequence[Column], /) -> DataFrame:
def assign(self, *columns: Column) -> DataFrame:
"""
Insert new column(s), or update values in existing ones.

Expand All @@ -197,7 +197,7 @@ def assign(self, columns: Column | Sequence[Column], /) -> DataFrame:

Parameters
----------
columns : Column | Sequence[Column]
*columns : Column
Column(s) to update/insert. If updating/inserting multiple columns,
they must all have different names.

Expand All @@ -207,13 +207,13 @@ def assign(self, columns: Column | Sequence[Column], /) -> DataFrame:
"""
...

def drop_columns(self, label: str | list[str]) -> DataFrame:
def drop_columns(self, *labels: str) -> DataFrame:
"""
Drop the specified column(s).

Parameters
----------
label : str | list[str]
*label : str
Column name(s) to drop.

Returns
Expand Down Expand Up @@ -266,8 +266,7 @@ def schema(self) -> dict[str, Any]:

def sort(
self,
keys: str | list[str] | None = None,
*,
*keys: str,
ascending: Sequence[bool] | bool = True,
nulls_position: Literal['first', 'last'] = 'last',
) -> DataFrame:
Expand All @@ -279,9 +278,9 @@ def sort(

Parameters
----------
keys : str | list[str], optional
*keys : str
Names of columns to sort by.
If `None`, sort by all columns.
If not specified, sort by all columns.
ascending : Sequence[bool] or bool
If `True`, sort by all keys in ascending order.
If `False`, sort by all keys in descending order.
Expand All @@ -307,8 +306,7 @@ def sort(

def sorted_indices(
self,
keys: str | list[str] | None = None,
*,
*keys: str,
ascending: Sequence[bool] | bool = True,
nulls_position: Literal['first', 'last'] = 'last',
) -> Column:
Expand All @@ -319,9 +317,9 @@ def sorted_indices(

Parameters
----------
keys : str | list[str], optional
*keys : str
Names of columns to sort by.
If `None`, sort by all columns.
If not specified, sort by all columns.
ascending : Sequence[bool] or bool
If `True`, sort by all keys in ascending order.
If `False`, sort by all keys in descending order.
Expand Down Expand Up @@ -796,15 +794,15 @@ def is_nan(self) -> DataFrame:
"""
...

def unique_indices(self, keys: str | list[str] | None = None, *, skip_nulls: bool = True) -> Column:
def unique_indices(self, *keys: str, skip_nulls: bool = True) -> Column:
"""
Return indices corresponding to unique values across selected columns.

Parameters
----------
keys : str | list[str], optional
*keys : str
Column names to consider when finding unique values.
If `None`, all columns are considered.
If not specified, all columns are considered.

Returns
-------
Expand Down