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

Disable construction of Index when freq is set in pandas-compatibility mode #13857

Merged
merged 2 commits into from
Aug 12, 2023
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: 6 additions & 0 deletions python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -2237,6 +2237,12 @@ def as_column(
raise NotImplementedError(
"cuDF does not yet support timezone-aware datetimes"
)
elif (
cudf.get_option("mode.pandas_compatible")
and isinstance(arbitrary, (pd.DatetimeIndex, pd.TimedeltaIndex))
and arbitrary.freq is not None
):
raise NotImplementedError("freq is not implemented yet")
else:
try:
data = as_column(
Expand Down
8 changes: 8 additions & 0 deletions python/cudf/cudf/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2670,3 +2670,11 @@ def test_index_mixed_dtype_error(data):
pi = pd.Index(data)
with pytest.raises(TypeError):
cudf.Index(pi)


@pytest.mark.parametrize("cls", [pd.DatetimeIndex, pd.TimedeltaIndex])
def test_index_date_duration_freq_error(cls):
s = cls([1, 2, 3], freq="infer")
with cudf.option_context("mode.pandas_compatible", True):
with pytest.raises(NotImplementedError):
cudf.Index(s)