pandas.tseries.offsets.SemiMonthEnd#
- class pandas.tseries.offsets.SemiMonthEnd#
Two DateOffset’s per month repeating on the last day of the month & day_of_month.
This offset allows for flexibility in generating date ranges or adjusting dates to the end of a month or a specific day in the month, such as the 15th or the last day of the month. It is useful for financial or scheduling applications where events occur bi-monthly.
- Parameters:
- nint, default 1
The number of months represented.
- normalizebool, default False
Normalize start/end dates to midnight before generating date range.
- day_of_monthint, {1, 3,…,27}, default 15
A specific integer for the day of the month.
Attributes
Return the day of the month for the semi-monthly offset.
See also
tseries.offsets.SemiMonthBeginOffset for semi-monthly frequencies, starting at the beginning of the month.
tseries.offsets.MonthEndOffset to the last calendar day of the month.
tseries.offsets.MonthBeginOffset to the first calendar day of the month.
Examples
>>> ts = pd.Timestamp(2022, 1, 14) >>> ts + pd.offsets.SemiMonthEnd() Timestamp('2022-01-15 00:00:00')
>>> ts = pd.Timestamp(2022, 1, 15) >>> ts + pd.offsets.SemiMonthEnd() Timestamp('2022-01-31 00:00:00')
>>> ts = pd.Timestamp(2022, 1, 31) >>> ts + pd.offsets.SemiMonthEnd() Timestamp('2022-02-15 00:00:00')
If you want to get the result for the current month:
>>> ts = pd.Timestamp(2022, 1, 15) >>> pd.offsets.SemiMonthEnd().rollforward(ts) Timestamp('2022-01-15 00:00:00')