Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.api.typing.Resampler.quantile PR01,PR07" \
-i "pandas.StringDtype.storage SA01" \
-i "pandas.tseries.offsets.BDay PR02,SA01" \
-i "pandas.tseries.offsets.BHalfYearBegin.is_on_offset GL08" \
-i "pandas.tseries.offsets.BHalfYearBegin.n GL08" \
-i "pandas.tseries.offsets.BHalfYearBegin.normalize GL08" \
-i "pandas.tseries.offsets.BHalfYearBegin.rule_code GL08" \
-i "pandas.tseries.offsets.BHalfYearBegin.startingMonth GL08" \
-i "pandas.tseries.offsets.BHalfYearEnd.is_on_offset GL08" \
-i "pandas.tseries.offsets.BHalfYearEnd.n GL08" \
-i "pandas.tseries.offsets.BHalfYearEnd.normalize GL08" \
-i "pandas.tseries.offsets.BHalfYearEnd.rule_code GL08" \
Expand Down Expand Up @@ -195,12 +193,10 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
-i "pandas.tseries.offsets.FY5253Quarter.variation GL08" \
-i "pandas.tseries.offsets.FY5253Quarter.weekday GL08" \
-i "pandas.tseries.offsets.FY5253Quarter.year_has_extra_week GL08" \
-i "pandas.tseries.offsets.HalfYearBegin.is_on_offset GL08" \
-i "pandas.tseries.offsets.HalfYearBegin.n GL08" \
-i "pandas.tseries.offsets.HalfYearBegin.normalize GL08" \
-i "pandas.tseries.offsets.HalfYearBegin.rule_code GL08" \
-i "pandas.tseries.offsets.HalfYearBegin.startingMonth GL08" \
-i "pandas.tseries.offsets.HalfYearEnd.is_on_offset GL08" \
-i "pandas.tseries.offsets.HalfYearEnd.n GL08" \
-i "pandas.tseries.offsets.HalfYearEnd.normalize GL08" \
-i "pandas.tseries.offsets.HalfYearEnd.rule_code GL08" \
Expand Down
38 changes: 38 additions & 0 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3131,6 +3131,44 @@ cdef class HalfYearOffset(SingleConstructorOffset):
return f"{self._prefix}-{month}"

def is_on_offset(self, dt: datetime) -> bool:
"""
Return boolean whether a timestamp intersects with this frequency.

This method checks if a given datetime falls on a valid half-year
boundary as defined by this offset.

Parameters
----------
dt : datetime
Timestamp to check intersections with frequency.

Returns
-------
bool
True if the timestamp is on the offset, False otherwise.

See Also
--------
HalfYearEnd.is_on_offset : Check if a timestamp is at the end of a
half-year.
HalfYearBegin.is_on_offset : Check if a timestamp is at the start of a
half-year.
BHalfYearEnd.is_on_offset : Check if a timestamp is at the end of a
business half-year.
BHalfYearBegin.is_on_offset : Check if a timestamp is at the start of a
business half-year.

Examples
--------
>>> freq = pd.offsets.BHalfYearBegin()
>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq.is_on_offset(ts)
False

>>> ts = pd.Timestamp(2022, 1, 3)
>>> freq.is_on_offset(ts)
True
"""
if self.normalize and not _is_normalized(dt):
return False
mod_month = (dt.month - self.startingMonth) % 6
Expand Down
Loading