Skip to content

Commit bac2992

Browse files
DOC: Fix GL08 for pandas.tseries.offsets.SemiMonthEnd.is_on_offset
1 parent 654a810 commit bac2992

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

ci/code_checks.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
8282
-i "pandas.tseries.offsets.LastWeekOfMonth.is_on_offset GL08" \
8383
-i "pandas.tseries.offsets.SemiMonthBegin.is_on_offset GL08" \
8484
-i "pandas.tseries.offsets.SemiMonthBegin.rule_code GL08" \
85-
-i "pandas.tseries.offsets.SemiMonthEnd.is_on_offset GL08" \
8685
-i "pandas.tseries.offsets.SemiMonthEnd.rule_code GL08" \
8786
-i "pandas.tseries.offsets.Week.is_on_offset GL08" \
8887
-i "pandas.tseries.offsets.WeekOfMonth.is_on_offset GL08" # There should be no backslash in the final line, please keep this comment in the last ignored function

pandas/_libs/tslibs/offsets.pyx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4631,6 +4631,44 @@ cdef class SemiMonthEnd(SemiMonthOffset):
46314631
_min_day_of_month = 1
46324632

46334633
def is_on_offset(self, dt: datetime) -> bool:
4634+
"""
4635+
Return boolean whether a timestamp intersects with this frequency.
4636+
4637+
This method determines if a given timestamp falls on either the
4638+
``day_of_month`` (default 15) or the last day of the month, which
4639+
are the two dates per month that this offset represents.
4640+
4641+
Parameters
4642+
----------
4643+
dt : datetime
4644+
Timestamp to check intersection with frequency.
4645+
4646+
Returns
4647+
-------
4648+
bool
4649+
True if the timestamp is on the offset, False otherwise.
4650+
4651+
See Also
4652+
--------
4653+
tseries.offsets.SemiMonthBegin.is_on_offset : Check if a timestamp falls
4654+
on a SemiMonthBegin offset.
4655+
tseries.offsets.MonthEnd.is_on_offset : Check if a timestamp falls
4656+
on a MonthEnd offset.
4657+
4658+
Examples
4659+
--------
4660+
>>> ts = pd.Timestamp(2022, 1, 15)
4661+
>>> pd.offsets.SemiMonthEnd().is_on_offset(ts)
4662+
True
4663+
4664+
>>> ts = pd.Timestamp(2022, 1, 31)
4665+
>>> pd.offsets.SemiMonthEnd().is_on_offset(ts)
4666+
True
4667+
4668+
>>> ts = pd.Timestamp(2022, 1, 14)
4669+
>>> pd.offsets.SemiMonthEnd().is_on_offset(ts)
4670+
False
4671+
"""
46344672
if self.normalize and not _is_normalized(dt):
46354673
return False
46364674
days_in_month = get_days_in_month(dt.year, dt.month)

0 commit comments

Comments
 (0)