Skip to content

Commit 346457d

Browse files
committed
bug-DatetimeIndex-is_year_start-breaks-on-freq-BusinessMonthStart
1 parent 3de26e0 commit 346457d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

pandas/_libs/tslibs/fields.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ def get_start_end_field(
253253
# month of year. Other offsets use month, startingMonth as ending
254254
# month of year.
255255

256-
if freq_name.lstrip("B")[0:2] in ["MS", "QS", "YS"]:
256+
if (freq_name.lstrip("B")[0:2] in ["MS", "QS", "YS"]) or (
257+
freq_name.lstrip("CB")[0:2] in ["MS", "QS", "YS"]):
257258
end_month = 12 if month_kw == 1 else month_kw - 1
258259
start_month = month_kw
259260
else:

pandas/tests/indexes/datetimes/test_scalar_compat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,8 @@ def test_dti_is_year_start_freq_custom_business_day_with_digit(self):
343343
msg = "Custom business days is not supported by is_year_start"
344344
with pytest.raises(ValueError, match=msg):
345345
dr.is_year_start
346+
347+
def test_dti_is_year_start_freq_business_month_start_with(self):
348+
dr = date_range("2020-01-01", periods=1, freq="CBMS")
349+
print(dr.is_year_start)
350+
# assert all(dr.is_year_start)

0 commit comments

Comments
 (0)