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 parameters similar to pandas 2.2 #14984

Merged
merged 4 commits into from
Feb 8, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions python/cudf/cudf/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -2402,6 +2402,11 @@ def __init__(
raise NotImplementedError("freq is not yet supported")

if unit is not None:
warnings.warn(
"The 'unit' keyword is "
"deprecated and will be removed in a future version. ",
FutureWarning,
)
raise NotImplementedError(
"unit is not yet supported, alternatively "
"dtype parameter is supported"
Expand Down
6 changes: 6 additions & 0 deletions python/cudf/cudf/core/indexed_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3921,6 +3921,12 @@ def resample(
"""
import cudf.core.resample

if kind is not None:
warnings.warn(
"The 'kind' keyword in is "
"deprecated and will be removed in a future version. ",
FutureWarning,
)
if (axis, convention, kind, loffset, base, origin, offset) != (
0,
"start",
Expand Down
8 changes: 8 additions & 0 deletions python/cudf/cudf/core/tools/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ def to_datetime(
f"{errors=} is not implemented when arg is not scalar-like"
)

if errors == "ignore":
warnings.warn(
"errors='ignore' is deprecated and will raise in a future version. "
"Use to_datetime without passing `errors` and catch exceptions "
"explicitly instead",
FutureWarning,
)

if infer_datetime_format in {None, False}:
warnings.warn(
"`infer_datetime_format` is deprecated and will "
Expand Down
7 changes: 7 additions & 0 deletions python/cudf/cudf/core/tools/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ def to_numeric(arg, errors="raise", downcast=None):

if errors not in {"raise", "ignore", "coerce"}:
raise ValueError("invalid error value specified")
elif errors == "ignore":
warnings.warn(
"errors='ignore' is deprecated and will raise in a future version. "
"Use to_numeric without passing `errors` and catch exceptions "
"explicitly instead",
FutureWarning,
)

if downcast not in {None, "integer", "signed", "unsigned", "float"}:
raise ValueError("invalid downcasting method provided")
Expand Down
5 changes: 5 additions & 0 deletions python/cudf/cudf/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -2468,3 +2468,8 @@ def test_datetime_raise_warning(freqstr):
)
with pytest.warns(FutureWarning):
t.dt.ceil(freqstr)


def test_to_datetime_errors_ignore_deprecated():
with pytest.warns(FutureWarning):
cudf.to_datetime("2001-01-01 00:04:45", errors="ignore")
9 changes: 6 additions & 3 deletions python/cudf/cudf/tests/test_numerical.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
import pytest

import cudf
from cudf.testing._utils import NUMERIC_TYPES, assert_eq
from cudf.core._compat import PANDAS_GE_220
from cudf.testing._utils import NUMERIC_TYPES, assert_eq, expect_warning_if
from cudf.utils.dtypes import np_dtypes_to_pandas_dtypes


Expand Down Expand Up @@ -372,8 +373,10 @@ def test_to_numeric_error(data, errors):
):
cudf.to_numeric(data, errors=errors)
else:
expect = pd.to_numeric(data, errors=errors)
got = cudf.to_numeric(data, errors=errors)
with expect_warning_if(PANDAS_GE_220 and errors == "ignore"):
expect = pd.to_numeric(data, errors=errors)
with expect_warning_if(errors == "ignore"):
got = cudf.to_numeric(data, errors=errors)

assert_eq(expect, got)

Expand Down