Skip to content

Commit

Permalink
Deprecate parameters similar to pandas 2.2 (#14984)
Browse files Browse the repository at this point in the history
For comparison:

pandas-dev/pandas#55856
pandas-dev/pandas#55895
pandas-dev/pandas#55499

The `errors="ignore"` parameter is the only one that is implemented so just added a test for that deprecation

Authors:
  - Matthew Roeschke (https://github.com/mroeschke)
  - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #14984
  • Loading branch information
mroeschke authored Feb 8, 2024
1 parent 47d28a0 commit 49c7d2c
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
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

0 comments on commit 49c7d2c

Please sign in to comment.