Skip to content

Commit 2d6be38

Browse files
authored
Adjust test_datetime_infer_format for pandas 2.2 (#15021)
pandas 2.2 is stricter about converting from date string to datetime type if the resolution would lead to loss of precision. This affects `test_datetime_infer_format` where an `astype` is done, so adjusting the test such that the `astypes` don't lead to loss of precision. Authors: - Matthew Roeschke (https://github.com/mroeschke) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) URL: #15021
1 parent c9dd325 commit 2d6be38

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

python/cudf/cudf/tests/test_datetime.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -1275,23 +1275,23 @@ def test_datetime_reductions(data, op, dtype):
12751275
assert_eq(expected, actual)
12761276

12771277

1278-
@pytest.mark.parametrize("timezone", ["naive", "UTC"])
1278+
@pytest.mark.parametrize("timezone", ["", "Z"])
12791279
@pytest.mark.parametrize(
12801280
"data",
12811281
[
1282-
np.arange("2002-10-27T04:30", 4 * 60, 60, dtype="M8[m]"),
1283-
np.arange("2002-10-27T04:30", 10 * 60, 1, dtype="M8[m]"),
1284-
np.arange("2002-10-27T04:30", 10 * 60, 1, dtype="M8[ns]"),
1285-
np.arange("2002-10-27T04:30", 10 * 60, 1, dtype="M8[us]"),
1286-
np.arange("2002-10-27T04:30", 4 * 60, 60, dtype="M8[s]"),
1282+
"2002-10-27T04:30",
1283+
"2002-10-27T04:30:00",
1284+
"2002-10-27T04:30:00.000",
1285+
"2002-10-27T04:30:00.000000",
1286+
"2002-10-27T04:30:00.000000000",
12871287
],
12881288
)
12891289
@pytest.mark.parametrize("dtype", DATETIME_TYPES)
12901290
def test_datetime_infer_format(data, timezone, dtype):
1291-
ts_data = np.datetime_as_string(data, timezone=timezone)
1291+
ts_data = [data + timezone]
12921292
sr = cudf.Series(ts_data)
12931293
psr = pd.Series(ts_data)
1294-
if timezone == "naive":
1294+
if not timezone:
12951295
expected = psr.astype(dtype)
12961296
actual = sr.astype(dtype)
12971297

0 commit comments

Comments
 (0)