Skip to content

Commit adcf608

Browse files
TST: add test for compatibility with numpy datetime64 pandas-dev#41617
1 parent da0156a commit adcf608

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pandas/tests/tseries/frequencies/test_freq_code.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
to_offset,
77
)
88
from pandas._libs.tslibs.dtypes import _attrname_to_abbrevs
9+
from numpy import datetime64
910

1011

1112
@pytest.mark.parametrize(
@@ -78,3 +79,20 @@ def test_cat(args):
7879

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

0 commit comments

Comments
 (0)