Skip to content

Commit 34177d6

Browse files
authored
BUG: DatetimeIndex.is_year_start breaks on custom business days frequencies bigger then 1C (#58665)
* fix bug dti.is_year_start breaks on freq custom business day with digit * rename the variable freqstr * delete double space
1 parent 56b6c8a commit 34177d6

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

doc/source/whatsnew/v3.0.0.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ Datetimelike
384384
- Bug in :func:`date_range` where the last valid timestamp would sometimes not be produced (:issue:`56134`)
385385
- Bug in :func:`date_range` where using a negative frequency value would not include all points between the start and end values (:issue:`56382`)
386386
- Bug in :func:`tseries.api.guess_datetime_format` would fail to infer time format when "%Y" == "%H%M" (:issue:`57452`)
387+
- Bug in :meth:`DatetimeIndex.is_year_start` and :meth:`DatetimeIndex.is_quarter_start` does not raise on Custom business days frequencies bigger then "1C" (:issue:`58664`)
388+
- Bug in :meth:`DatetimeIndex.is_year_start` and :meth:`DatetimeIndex.is_quarter_start` returning ``False`` on double-digit frequencies (:issue:`58523`)
387389
- Bug in setting scalar values with mismatched resolution into arrays with non-nanosecond ``datetime64``, ``timedelta64`` or :class:`DatetimeTZDtype` incorrectly truncating those scalars (:issue:`56410`)
388390

389391
Timedelta
@@ -421,7 +423,6 @@ Interval
421423
Indexing
422424
^^^^^^^^
423425
- Bug in :meth:`DataFrame.__getitem__` returning modified columns when called with ``slice`` in Python 3.12 (:issue:`57500`)
424-
- Bug in :meth:`DatetimeIndex.is_year_start` and :meth:`DatetimeIndex.is_quarter_start` returning ``False`` on double-digit frequencies (:issue:`58523`)
425426
-
426427

427428
Missing

pandas/_libs/tslibs/fields.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ 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"]:
257257
end_month = 12 if month_kw == 1 else month_kw - 1
258258
start_month = month_kw
259259
else:

pandas/tests/indexes/datetimes/test_scalar_compat.py

+7
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,10 @@ def test_dti_is_year_quarter_start_doubledigit_freq(self):
336336

337337
dr = date_range("2017-01-01", periods=2, freq="10QS")
338338
assert all(dr.is_quarter_start)
339+
340+
def test_dti_is_year_start_freq_custom_business_day_with_digit(self):
341+
# GH#58664
342+
dr = date_range("2020-01-01", periods=2, freq="2C")
343+
msg = "Custom business days is not supported by is_year_start"
344+
with pytest.raises(ValueError, match=msg):
345+
dr.is_year_start

0 commit comments

Comments
 (0)