Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import datetime as dt
import pandas as pd
end = dt.datetime(2025, 7, 26, 6) # Saturday early morning
for d in range(18, 22): # Friday, Saturday, Sunday & Monday
start = dt.datetime(2025, 7, d, 10)
print(f"start={start}: {pd.date_range(start, end, freq="B")}\n")
Issue Description
Running date_range
with varying start
and fixed end
gives outputs differing final entries when freq="B"
. Specifically, in the above example, the first and last iteration are missing an entry for 2025-07-25 10:00:00
.
Expected Behavior
The last three iterations in the above code should produce the same output, and the first iteration should differ from the other three only in that it additionally includes 2025-07-18 10:00:00
as a first entry. Instead the output is the following:
start=2025-07-18 10:00:00: DatetimeIndex(['2025-07-18 10:00:00', '2025-07-21 10:00:00',
'2025-07-22 10:00:00', '2025-07-23 10:00:00',
'2025-07-24 10:00:00'],
dtype='datetime64[ns]', freq='B')
start=2025-07-19 10:00:00: DatetimeIndex(['2025-07-21 10:00:00', '2025-07-22 10:00:00',
'2025-07-23 10:00:00', '2025-07-24 10:00:00',
'2025-07-25 10:00:00'],
dtype='datetime64[ns]', freq='B')
start=2025-07-20 10:00:00: DatetimeIndex(['2025-07-21 10:00:00', '2025-07-22 10:00:00',
'2025-07-23 10:00:00', '2025-07-24 10:00:00',
'2025-07-25 10:00:00'],
dtype='datetime64[ns]', freq='B')
start=2025-07-21 10:00:00: DatetimeIndex(['2025-07-21 10:00:00', '2025-07-22 10:00:00',
'2025-07-23 10:00:00', '2025-07-24 10:00:00'],
dtype='datetime64[ns]', freq='B')
Installed Versions
Comment From: torext
It looks like this very old issue https://github.com/pandas-dev/pandas/issues/35342 might be related to this, as in addition to the example I gave above I've observed other variations of it where the output is expected etc.
Comment From: rhshadrach
Thanks for the report! I am seeing all end on 2025-07-25 10:00:00
on main. There are a number of fixes in this regard coming in 3.0; closing.