Skip to content

Commit e420c24

Browse files
committed
BUG: BDay() offsetting not behaving as expected
1 parent 22dbef1 commit e420c24

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

pandas/tests/tseries/offsets/test_offsets.py

+71
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import numpy as np
66
import pytest
77

8+
import pandas as pd
9+
from pandas.tseries.offsets import BDay
10+
811
from pandas._libs.tslibs import (
912
NaT,
1013
OutOfBoundsDatetime,
@@ -2326,6 +2329,74 @@ def test_datetimeindex(self):
23262329
for idx in [idx1, idx2, idx3]:
23272330
tm.assert_index_equal(idx, expected)
23282331

2332+
def test_bday_ignores_timedeltas(self):
2333+
idx = pd.date_range("2010/02/01", "2010/02/15", freq="6H")
2334+
t1 = idx + BDay(offset=pd.Timedelta(3, unit="H"))
2335+
2336+
expected = DatetimeIndex(
2337+
[
2338+
"2010-02-02 03:00:00",
2339+
"2010-02-02 09:00:00",
2340+
"2010-02-02 15:00:00",
2341+
"2010-02-02 21:00:00",
2342+
"2010-02-03 03:00:00",
2343+
"2010-02-03 09:00:00",
2344+
"2010-02-03 15:00:00",
2345+
"2010-02-03 21:00:00",
2346+
"2010-02-04 03:00:00",
2347+
"2010-02-04 09:00:00",
2348+
"2010-02-04 15:00:00",
2349+
"2010-02-04 21:00:00",
2350+
"2010-02-05 03:00:00",
2351+
"2010-02-05 09:00:00",
2352+
"2010-02-05 15:00:00",
2353+
"2010-02-05 21:00:00",
2354+
"2010-02-08 03:00:00",
2355+
"2010-02-08 09:00:00",
2356+
"2010-02-08 15:00:00",
2357+
"2010-02-08 21:00:00",
2358+
"2010-02-08 03:00:00",
2359+
"2010-02-08 09:00:00",
2360+
"2010-02-08 15:00:00",
2361+
"2010-02-08 21:00:00",
2362+
"2010-02-08 03:00:00",
2363+
"2010-02-08 09:00:00",
2364+
"2010-02-08 15:00:00",
2365+
"2010-02-08 21:00:00",
2366+
"2010-02-09 03:00:00",
2367+
"2010-02-09 09:00:00",
2368+
"2010-02-09 15:00:00",
2369+
"2010-02-09 21:00:00",
2370+
"2010-02-10 03:00:00",
2371+
"2010-02-10 09:00:00",
2372+
"2010-02-10 15:00:00",
2373+
"2010-02-10 21:00:00",
2374+
"2010-02-11 03:00:00",
2375+
"2010-02-11 09:00:00",
2376+
"2010-02-11 15:00:00",
2377+
"2010-02-11 21:00:00",
2378+
"2010-02-12 03:00:00",
2379+
"2010-02-12 09:00:00",
2380+
"2010-02-12 15:00:00",
2381+
"2010-02-12 21:00:00",
2382+
"2010-02-15 03:00:00",
2383+
"2010-02-15 09:00:00",
2384+
"2010-02-15 15:00:00",
2385+
"2010-02-15 21:00:00",
2386+
"2010-02-15 03:00:00",
2387+
"2010-02-15 09:00:00",
2388+
"2010-02-15 15:00:00",
2389+
"2010-02-15 21:00:00",
2390+
"2010-02-15 03:00:00",
2391+
"2010-02-15 09:00:00",
2392+
"2010-02-15 15:00:00",
2393+
"2010-02-15 21:00:00",
2394+
"2010-02-16 03:00:00",
2395+
],
2396+
freq=None,
2397+
)
2398+
tm.assert_index_equal(t1, expected)
2399+
23292400

23302401
class TestCustomBusinessHour(Base):
23312402
_offset = CustomBusinessHour

0 commit comments

Comments
 (0)