Skip to content

Commit

Permalink
REFACTOR-modin-project#7418: Rename to_dataframe to to_interchange_da…
Browse files Browse the repository at this point in the history
…taframe.

Signed-off-by: sfc-gh-mvashishtha <[email protected]>
  • Loading branch information
sfc-gh-mvashishtha committed Jan 16, 2025
1 parent caa6116 commit 0e57d6b
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 7 deletions.
4 changes: 3 additions & 1 deletion modin/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ def from_arrow(cls, at, data_cls):
def free(self):
pass

def to_dataframe(self, nan_as_null: bool = False, allow_copy: bool = True):
def to_interchange_dataframe(
self, nan_as_null: bool = False, allow_copy: bool = True
):
raise NotImplementedError(
"The selected execution does not implement the DataFrame exchange protocol."
)
Expand Down
7 changes: 6 additions & 1 deletion modin/core/storage_formats/base/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@
StrDefault,
StructDefault,
)
from modin.core.dataframe.base.interchange.dataframe_protocol.dataframe import (
ProtocolDataframe,
)
from modin.error_message import ErrorMessage
from modin.logging import ClassLogger
from modin.logging.config import LogLevel
Expand Down Expand Up @@ -472,7 +475,9 @@ def to_numpy(self, **kwargs): # noqa: PR02
# Dataframe exchange protocol

@abc.abstractmethod
def to_dataframe(self, nan_as_null: bool = False, allow_copy: bool = True):
def to_interchange_dataframe(
self, nan_as_null: bool = False, allow_copy: bool = True
) -> ProtocolDataframe:
"""
Get a DataFrame exchange protocol object representing data of the Modin DataFrame.
Expand Down
4 changes: 3 additions & 1 deletion modin/core/storage_formats/pandas/native_query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,9 @@ def finalize(self):

# Dataframe exchange protocol

def to_dataframe(self, nan_as_null: bool = False, allow_copy: bool = True):
def to_interchange_dataframe(
self, nan_as_null: bool = False, allow_copy: bool = True
):
return self._modin_frame.__dataframe__(
nan_as_null=nan_as_null, allow_copy=allow_copy
)
Expand Down
4 changes: 3 additions & 1 deletion modin/core/storage_formats/pandas/query_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,9 @@ def from_arrow(cls, at, data_cls):

# Dataframe exchange protocol

def to_dataframe(self, nan_as_null: bool = False, allow_copy: bool = True):
def to_interchange_dataframe(
self, nan_as_null: bool = False, allow_copy: bool = True
):
return self._modin_frame.__dataframe__(
nan_as_null=nan_as_null, allow_copy=allow_copy
)
Expand Down
2 changes: 1 addition & 1 deletion modin/pandas/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2917,7 +2917,7 @@ def __dataframe__(self, nan_as_null: bool = False, allow_copy: bool = True):
ProtocolDataframe
A dataframe object following the dataframe protocol specification.
"""
return self._query_compiler.to_dataframe(
return self._query_compiler.to_interchange_dataframe(
nan_as_null=nan_as_null, allow_copy=allow_copy
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def dummy_io_method(*args, **kwargs):

query_compiler_cls = get_unique_base_execution
query_compiler_cls.from_dataframe = dummy_io_method
query_compiler_cls.to_dataframe = dummy_io_method
query_compiler_cls.to_interchange_dataframe = dummy_io_method

from modin.pandas.io import from_dataframe

Expand Down
2 changes: 1 addition & 1 deletion modin/tests/test_executions_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_base_abstract_methods():
"from_arrow",
"default_to_pandas",
"from_dataframe",
"to_dataframe",
"to_interchange_dataframe",
]

not_implemented_methods = BASE_EXECUTION.__abstractmethods__.difference(
Expand Down

0 comments on commit 0e57d6b

Please sign in to comment.