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

Support IntervalDtype in cudf.from_pandas #16014

Merged
Merged
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
6 changes: 3 additions & 3 deletions python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8072,11 +8072,11 @@ def from_pandas(obj, nan_as_null=no_default):
return cudf.Index.from_pandas(obj, nan_as_null=nan_as_null)
elif isinstance(obj, pd.CategoricalDtype):
return cudf.CategoricalDtype.from_pandas(obj)
elif isinstance(obj, pd.IntervalDtype):
return cudf.IntervalDtype.from_pandas(obj)
else:
raise TypeError(
"from_pandas only accepts Pandas Dataframes, Series, "
"Index, RangeIndex and MultiIndex objects. "
"Got %s" % type(obj)
f"from_pandas unsupported for object of type {type(obj).__name__}"
)


Expand Down
7 changes: 7 additions & 0 deletions python/cudf/cudf/tests/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,10 @@ def test_interval_with_datetime(tz, box):
else:
with pytest.raises(NotImplementedError):
cudf.from_pandas(pobj)


def test_from_pandas_intervaldtype():
dtype = pd.IntervalDtype("int64", closed="left")
result = cudf.from_pandas(dtype)
expected = cudf.IntervalDtype("int64", closed="left")
assert_eq(result, expected)
Loading