Skip to content

Commit 89d955f

Browse files
TST: add test for compatibility with numpy datetime64 (#45766)
* TST: add test for compatibility with numpy datetime64 #41617 * TST; add test for compatibility with numpy datetime64 (#41617) * Fixed a fat finger error in one of the expected values * Fixes from pre-commit [automated commit] * changed numpy import
1 parent 1536e45 commit 89d955f

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

pandas/tests/tseries/frequencies/test_freq_code.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import numpy as np
12
import pytest
23

34
from pandas._libs.tslibs import (
@@ -78,3 +79,19 @@ def test_cat(args):
7879

7980
with pytest.raises(ValueError, match=msg):
8081
to_offset(str(args[0]) + args[1])
82+
83+
84+
@pytest.mark.parametrize(
85+
"freqstr,expected",
86+
[
87+
("1H", "2021-01-01T09:00:00"),
88+
("1D", "2021-01-02T08:00:00"),
89+
("1W", "2021-01-03T08:00:00"),
90+
("1M", "2021-01-31T08:00:00"),
91+
("1Y", "2021-12-31T08:00:00"),
92+
],
93+
)
94+
def test_compatibility(freqstr, expected):
95+
ts_np = np.datetime64("2021-01-01T08:00:00.00")
96+
do = to_offset(freqstr)
97+
assert ts_np + do == np.datetime64(expected)

0 commit comments

Comments
 (0)