Skip to content

add Column.__dataframe_namespace__ #175

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
Jun 20, 2023
Merged
Show file tree
Hide file tree
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
30 changes: 29 additions & 1 deletion spec/API_specification/dataframe_api/column_object.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import NoReturn, Sequence, TYPE_CHECKING
from typing import Any, NoReturn, Sequence, TYPE_CHECKING

if TYPE_CHECKING:
from ._types import Scalar, DType
Expand All @@ -18,6 +18,34 @@ class Column:
constructor functions or an already-created dataframe object retrieved via

"""

def __column_namespace__(
self: Column, /, *, api_version: str | None = None
) -> Any:
"""
Returns an object that has all the Dataframe Standard API functions on it.

Parameters
----------
api_version: Optional[str]
String representing the version of the dataframe API specification
to be returned, in ``'YYYY.MM'`` form, for example, ``'2023.04'``.
If it is ``None``, it should return the namespace corresponding to
latest version of the dataframe API specification. If the given
version is invalid or not implemented for the given module, an
error should be raised. Default: ``None``.

Returns
-------
namespace: Any
An object representing the dataframe API namespace. It should have
every top-level function defined in the specification as an
attribute. It may contain other public names as well, but it is
recommended to only include those names that are part of the
specification.

"""

def __len__(self) -> int:
"""
Return the number of rows.
Expand Down
4 changes: 2 additions & 2 deletions spec/API_specification/dataframe_api/dataframe_object.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Literal, Mapping, Sequence, Union, TYPE_CHECKING, NoReturn
from typing import Any, Literal, Mapping, Sequence, Union, TYPE_CHECKING, NoReturn


if TYPE_CHECKING:
Expand Down Expand Up @@ -37,7 +37,7 @@ class DataFrame:

"""
def __dataframe_namespace__(
self: DataFrame, /, *, api_version: Optional[str] = None
self: DataFrame, /, *, api_version: str | None = None
) -> Any:
"""
Returns an object that has all the dataframe API functions on it.
Expand Down