pandas.tseries.offsets.BusinessDay#

class pandas.tseries.offsets.BusinessDay#

表示可能 n 个工作日的 DateOffset 子类。

参数:
nint, default 1

表示的天数。

normalizebool,默认为 False

将开始/结束日期规范化为午夜。

offsettimedelta, default timedelta(0)

要应用的日期偏移量。

示例

您可以使用参数 n 来表示 n 个工作日的偏移。

>>> ts = pd.Timestamp(2022, 12, 9, 15)
>>> ts.strftime('%a %d %b %Y %H:%M')
'Fri 09 Dec 2022 15:00'
>>> (ts + pd.offsets.BusinessDay(n=5)).strftime('%a %d %b %Y %H:%M')
'Fri 16 Dec 2022 15:00'

将参数 normalize 设置为 True,可以将下一个工作日的开始时间偏移到午夜。

>>> ts = pd.Timestamp(2022, 12, 9, 15)
>>> ts + pd.offsets.BusinessDay(normalize=True)
Timestamp('2022-12-12 00:00:00')

属性

base

Returns a copy of the calling offset object with n=1 and all other attributes equal.

calendar

返回用于营业日计算的日历。

freqstr

Return a string representing the frequency.

holidays

返回用于自定义营业日计算的节假日。

kwds

Return a dict of extra parameters for the offset.

n

Return the count of the number of periods.

name

Return a string representing the base frequency.

nanos

Returns an integer of the total number of nanoseconds for fixed frequencies.

normalize

Return boolean whether the frequency can align with midnight.

偏移量

self._offset 的别名。

rule_code

Return a string representing the base frequency.

weekmask

返回用于自定义营业日计算的周掩码。

Methods

copy()

Return a copy of the frequency.

is_month_end(ts)

Return boolean whether a timestamp occurs on the month end.

is_month_start(ts)

Return boolean whether a timestamp occurs on the month start.

is_on_offset(dt)

Return boolean whether a timestamp intersects with this frequency.

is_quarter_end(ts)

Return boolean whether a timestamp occurs on the quarter end.

is_quarter_start(ts)

Return boolean whether a timestamp occurs on the quarter start.

is_year_end(ts)

Return boolean whether a timestamp occurs on the year end.

is_year_start(ts)

Return boolean whether a timestamp occurs on the year start.

rollback(dt)

Roll provided date backward to next offset only if not on offset.

rollforward(dt)

Roll provided date forward to next offset only if not on offset.