Skip to content

Commit 5df2ede

Browse files
authored
add Column.__dataframe_namespace__ (#175)
1 parent 5dd4173 commit 5df2ede

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

spec/API_specification/dataframe_api/column_object.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import NoReturn, Sequence, TYPE_CHECKING
3+
from typing import Any, NoReturn, Sequence, TYPE_CHECKING
44

55
if TYPE_CHECKING:
66
from ._types import Scalar
@@ -19,6 +19,34 @@ class Column:
1919
constructor functions or an already-created dataframe object retrieved via
2020
2121
"""
22+
23+
def __column_namespace__(
24+
self: Column, /, *, api_version: str | None = None
25+
) -> Any:
26+
"""
27+
Returns an object that has all the Dataframe Standard API functions on it.
28+
29+
Parameters
30+
----------
31+
api_version: Optional[str]
32+
String representing the version of the dataframe API specification
33+
to be returned, in ``'YYYY.MM'`` form, for example, ``'2023.04'``.
34+
If it is ``None``, it should return the namespace corresponding to
35+
latest version of the dataframe API specification. If the given
36+
version is invalid or not implemented for the given module, an
37+
error should be raised. Default: ``None``.
38+
39+
Returns
40+
-------
41+
namespace: Any
42+
An object representing the dataframe API namespace. It should have
43+
every top-level function defined in the specification as an
44+
attribute. It may contain other public names as well, but it is
45+
recommended to only include those names that are part of the
46+
specification.
47+
48+
"""
49+
2250
def __len__(self) -> int:
2351
"""
2452
Return the number of rows.

spec/API_specification/dataframe_api/dataframe_object.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22

3-
from typing import Literal, Mapping, Sequence, Union, TYPE_CHECKING, NoReturn
3+
from typing import Any, Literal, Mapping, Sequence, Union, TYPE_CHECKING, NoReturn
44

55

66
if TYPE_CHECKING:
@@ -37,7 +37,7 @@ class DataFrame:
3737
3838
"""
3939
def __dataframe_namespace__(
40-
self: DataFrame, /, *, api_version: Optional[str] = None
40+
self: DataFrame, /, *, api_version: str | None = None
4141
) -> Any:
4242
"""
4343
Returns an object that has all the dataframe API functions on it.

0 commit comments

Comments
 (0)