Skip to content
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

Deprecate dataframe protocol #17736

Open
wants to merge 2 commits into
base: branch-25.02
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import pandas as pd
import pyarrow as pa
from nvtx import annotate
from packaging import version
from pandas.io.formats import console
from pandas.io.formats.printing import pprint_thing
from typing_extensions import Self, assert_never
Expand Down Expand Up @@ -5562,6 +5563,12 @@ def from_pandas(cls, dataframe, nan_as_null=no_default):
elif hasattr(dataframe, "__dataframe__"):
# TODO: Probably should be handled in the constructor as
# this isn't pandas specific
assert version.parse(cudf.__version__) < version.parse("25.04.00")
warnings.warn(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to filter this warning too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't because that branch wasn't tested before 🙃 I thought about it but then skipped it since it's already untested and we're removing this code next release anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool thanks, LGTM

"Support for loading dataframes via the `__dataframe__` interchange "
"protocol is deprecated",
FutureWarning,
)
return from_dataframe(dataframe, allow_copy=True)
else:
raise TypeError(
Expand Down Expand Up @@ -7709,6 +7716,8 @@ def pct_change(
def __dataframe__(
self, nan_as_null: bool = False, allow_copy: bool = True
):
assert version.parse(cudf.__version__) < version.parse("25.04.00")
warnings.warn("Using `__dataframe__` is deprecated", FutureWarning)
return df_protocol.__dataframe__(
self, nan_as_null=nan_as_null, allow_copy=allow_copy
)
Expand Down
6 changes: 5 additions & 1 deletion python/cudf/cudf/tests/test_df_protocol.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2021-2024, NVIDIA CORPORATION.
# Copyright (c) 2021-2025, NVIDIA CORPORATION.
from __future__ import annotations

from typing import Any
Expand All @@ -22,6 +22,10 @@
)
from cudf.testing import assert_eq

pytestmark = pytest.mark.filterwarnings(
"ignore:Using `__dataframe__` is deprecated:FutureWarning"
)


@pytest.fixture(
params=[
Expand Down
Loading