Skip to content

Commit

Permalink
Support pd.read_pickle and pd.to_pickle in cudf.pandas (#16105)
Browse files Browse the repository at this point in the history
Closes #15459

Authors:
  - Matthew Murray (https://github.com/Matt711)

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)
  - Matthew Roeschke (https://github.com/mroeschke)
  - Lawrence Mitchell (https://github.com/wence-)

URL: #16105
  • Loading branch information
Matt711 authored Jul 9, 2024
1 parent 433e959 commit 341e014
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/cudf/cudf/pandas/_wrappers/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,12 @@ def Index__new__(cls, *args, **kwargs):

_eval_func = _FunctionProxy(_Unusable(), pd.eval)

register_proxy_func(pd.read_pickle)(
_FunctionProxy(_Unusable(), pd.read_pickle)
)

register_proxy_func(pd.to_pickle)(_FunctionProxy(_Unusable(), pd.to_pickle))


def _get_eval_locals_and_globals(level, local_dict=None, global_dict=None):
frame = sys._getframe(level + 3)
Expand Down
7 changes: 7 additions & 0 deletions python/cudf/cudf_pandas_tests/test_cudf_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,13 @@ def test_pickle(obj):

tm.assert_equal(obj, copy)

with tempfile.TemporaryFile() as f:
xpd.to_pickle(obj, f)
f.seek(0)
copy = xpd.read_pickle(f)

tm.assert_equal(obj, copy)


def test_dataframe_query():
cudf_pandas_df = xpd.DataFrame({"foo": [1, 2, 3], "bar": [4, 5, 6]})
Expand Down

0 comments on commit 341e014

Please sign in to comment.