Skip to content

ENH: add consortium standard entrypoint #54383

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 12 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 15 additions & 0 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,21 @@ def __dataframe__(

return PandasDataFrameXchg(self, nan_as_null, allow_copy)

def __dataframe_consortium_standard__(
self, *, api_version: str | None = None
) -> Any:
"""
Provide entry point to the Consortium DataFrame Standard API.

This is developed and maintained outside of pandas.
Please report any issues to https://github.com/data-apis/dataframe-api-compat.
"""
dataframe_api_compat = import_optional_dependency("dataframe_api_compat")
convert_to_standard_compliant_dataframe = (
dataframe_api_compat.pandas_standard.convert_to_standard_compliant_dataframe
)
return convert_to_standard_compliant_dataframe(self, api_version=api_version)

# ----------------------------------------------------------------------

@property
Expand Down
17 changes: 17 additions & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from pandas._libs.lib import is_range_indexer
from pandas.compat import PYPY
from pandas.compat._constants import REF_COUNT
from pandas.compat._optional import import_optional_dependency
from pandas.compat.numpy import function as nv
from pandas.errors import (
ChainedAssignmentError,
Expand Down Expand Up @@ -955,6 +956,22 @@ def __array__(self, dtype: npt.DTypeLike | None = None) -> np.ndarray:
arr.flags.writeable = False
return arr

# ----------------------------------------------------------------------

def __column_consortium_standard__(self, *, api_version: str | None = None) -> Any:
"""
Provide entry point to the Consortium DataFrame Standard API.

This is developed and maintained outside of pandas.
Please report any issues to https://github.com/data-apis/dataframe-api-compat.
"""
dataframe_api_compat = import_optional_dependency("dataframe_api_compat")
return (
dataframe_api_compat.pandas_standard.convert_to_standard_compliant_column(
self, api_version=api_version
)
)

# ----------------------------------------------------------------------
# Unary Methods

Expand Down