Skip to content

Commit caa2de5

Browse files
theonikoluckyvs1
authored andcommitted
BUG: BDay() offsetting not behaving as expected (pandas-dev#38324)
1 parent 133d247 commit caa2de5

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

pandas/tests/tseries/offsets/test_offsets.py

+31-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,9 @@
1919
from pandas.compat.numpy import np_datetime64_compat
2020
from pandas.errors import PerformanceWarning
2121

22+
from pandas import DatetimeIndex, Series, Timedelta, date_range, read_pickle
2223
import pandas._testing as tm
23-
from pandas.core.indexes.datetimes import DatetimeIndex, date_range
24-
from pandas.core.series import Series
2524

26-
from pandas.io.pickle import read_pickle
2725
from pandas.tseries.holiday import USFederalHolidayCalendar
2826
import pandas.tseries.offsets as offsets
2927
from pandas.tseries.offsets import (
@@ -2326,6 +2324,36 @@ def test_datetimeindex(self):
23262324
for idx in [idx1, idx2, idx3]:
23272325
tm.assert_index_equal(idx, expected)
23282326

2327+
def test_bday_ignores_timedeltas(self):
2328+
idx = date_range("2010/02/01", "2010/02/10", freq="12H")
2329+
t1 = idx + BDay(offset=Timedelta(3, unit="H"))
2330+
2331+
expected = DatetimeIndex(
2332+
[
2333+
"2010-02-02 03:00:00",
2334+
"2010-02-02 15:00:00",
2335+
"2010-02-03 03:00:00",
2336+
"2010-02-03 15:00:00",
2337+
"2010-02-04 03:00:00",
2338+
"2010-02-04 15:00:00",
2339+
"2010-02-05 03:00:00",
2340+
"2010-02-05 15:00:00",
2341+
"2010-02-08 03:00:00",
2342+
"2010-02-08 15:00:00",
2343+
"2010-02-08 03:00:00",
2344+
"2010-02-08 15:00:00",
2345+
"2010-02-08 03:00:00",
2346+
"2010-02-08 15:00:00",
2347+
"2010-02-09 03:00:00",
2348+
"2010-02-09 15:00:00",
2349+
"2010-02-10 03:00:00",
2350+
"2010-02-10 15:00:00",
2351+
"2010-02-11 03:00:00",
2352+
],
2353+
freq=None,
2354+
)
2355+
tm.assert_index_equal(t1, expected)
2356+
23292357

23302358
class TestCustomBusinessHour(Base):
23312359
_offset = CustomBusinessHour

0 commit comments

Comments
 (0)