Pandas-2-2-中文文档-三十-

Pandas 2.2 中文文档(三十)

原文:pandas.pydata.org/docs/

pandas.tseries.offsets.DateOffset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.html

class pandas.tseries.offsets.DateOffset

用于日期范围的标准日期增量类型。

与 relativedelta 的关键字参数形式完全相同。请注意,不支持 relativedelata 的位置参数形式。不建议使用关键字 n —— 最好在使用的关键字中指定 n,但无论如何,它都在那里。对于 DateOffset 子类,需要 n。

DateOffset 的工作方式如下。每个偏移量指定符合 DateOffset 的日期集。例如,Bday 将此集定义为工作日(周一至周五)的日期集。要测试日期是否在 DateOffset 的日期集中,可以使用 is_on_offset 方法:dateOffset.is_on_offset(date)。

如果日期不在有效日期上,则可以使用回滚和向前滚动方法将日期滚动到日期之前/之后的最近有效日期。

DateOffsets 可以创建以将日期向前移动给定数量的有效日期。例如,Bday(2) 可以添加到日期中,使其向前移动两个工作日。如果日期不是从有效日期开始的,则首先将其移动到有效日期。因此,伪代码如下:

def __add__(date):
  date = rollback(date) # does nothing if date is valid
  return date + <n number of periods> 

当为负数创建日期偏移时,日期首先向前滚动。伪代码如下:

def __add__(date):
  date = rollforward(date) # does nothing if date is valid
  return date + <n number of periods> 

零会带来问题。应该向前滚动还是向后滚动?我们任意地选择向前滚动:

date + BDay(0) == BDay.rollforward(date)

由于 0 有点奇怪,我们建议避免使用它。

此外,可以通过使用日期组件的单数形式指定的 DateOffsets 来替换时间戳的某些组件。

参数:

nint,默认为 1

偏移量代表的时间段数。如果没有指定时间模式,默认为 n 天。

normalizebool,默认为 False

是否将 DateOffset 添加的结果四舍五入到前一天的午夜。

weekdayint {0, 1, …, 6},默认为 0

一周中特定的整数。

  • 0 是星期一

  • 1 是星期二

  • 2 是星期三

  • 3 是星期四

  • 4 是星期五

  • 5 是星期六

  • 6 是星期日

可以使用 dateutil.relativedelta 中的 Weekday 类型。

  • MO 是星期一

  • TU 是星期二

  • WE 是星期三

  • TH 是星期四

  • FR 是星期五

  • SA 是星期六

  • SU 是星期日。

**kwds

添加到或替换偏移值的时间参数。

添加到偏移量的参数(类似于 Timedelta):

  • 小时

  • 分钟

  • 毫秒

  • 微秒

  • 纳秒

替换偏移值的参数:

  • 工作日

  • 小时

  • 分钟

  • 微秒

  • 纳秒

另请参阅

dateutil.relativedelta.relativedelta

relativedelta 类型旨在应用于现有日期时间,并可以替换该日期时间的特定组件,或表示一段时间间隔。

示例

>>> from pandas.tseries.offsets import DateOffset
>>> ts = pd.Timestamp('2017-01-01 09:10:11')
>>> ts + DateOffset(months=3)
Timestamp('2017-04-01 09:10:11') 
>>> ts = pd.Timestamp('2017-01-01 09:10:11')
>>> ts + DateOffset(months=2)
Timestamp('2017-03-01 09:10:11')
>>> ts + DateOffset(day=31)
Timestamp('2017-01-31 09:10:11') 
>>> ts + pd.DateOffset(hour=8)
Timestamp('2017-01-01 08:10:11') 

属性

base 返回调用偏移对象的副本,其中 n=1,所有其他属性相等。
freqstr 返回表示频率的字符串。
kwds 返回偏移的额外参数的字典。
n
name 返回表示基础频率的字符串。
nanos
normalize
rule_code

方法

copy() 返回频率的副本。
is_anchored() (已弃用) 返回布尔值,指示频率是否为单位频率(n=1)。
is_month_end(ts) 返回布尔值,指示时间戳是否发生在月末。
is_month_start(ts) 返回布尔值,指示时间戳是否发生在月初。
is_on_offset(dt) 返回布尔值,指示时间戳是否与此频率相交。
is_quarter_end(ts) 返回布尔值,指示时间戳是否发生在季度结束。
is_quarter_start(ts) 返回布尔值,指示时间戳是否发生在季度开始。
is_year_end(ts) 返回布尔值,表示时间戳是否发生在年末。
is_year_start(ts) 返回布尔值,表示时间戳是否发生在年初。
rollback(dt) 仅当日期不在偏移量上时,将提供的日期向后滚动到下一个偏移量。
rollforward(dt) 仅当日期不在偏移量上时,将提供的日期向前滚动到下一个偏移量。

pandas.tseries.offsets.DateOffset.freqstr

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.freqstr.html

DateOffset.freqstr

返回表示频率的字符串。

示例

>>> pd.DateOffset(5).freqstr
'<5 * DateOffsets>' 
>>> pd.offsets.BusinessHour(2).freqstr
'2bh' 
>>> pd.offsets.Nano().freqstr
'ns' 
>>> pd.offsets.Nano(-3).freqstr
'-3ns' 

pandas.tseries.offsets.DateOffset.kwds

pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.kwds.html

DateOffset.kwds

返回偏移量的额外参数字典。

示例

>>> pd.DateOffset(5).kwds
{} 
>>> pd.offsets.FY5253Quarter().kwds
{'weekday': 0,
 'startingMonth': 1,
 'qtr_with_extra_week': 1,
 'variation': 'nearest'} 

pandas.tseries.offsets.DateOffset.name

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.name.html

DateOffset.name

返回表示基础频率的字符串。

示例

>>> pd.offsets.Hour().name
'h' 
>>> pd.offsets.Hour(5).name
'h' 

pandas.tseries.offsets.DateOffset.nanos

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.nanos.html

DateOffset.nanos

pandas.tseries.offsets.DateOffset.normalize

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.normalize.html

DateOffset.normalize

pandas.tseries.offsets.DateOffset.rule_code

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.rule_code.html

DateOffset.rule_code

pandas.tseries.offsets.DateOffset.n

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.n.html

DateOffset.n

pandas.tseries.offsets.DateOffset.is_month_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.is_month_start.html

DateOffset.is_month_start(ts)

返回一个布尔值,指示时间戳是否出现在月初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.DateOffset.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.is_month_end.html

DateOffset.is_month_end(ts)

返回一个布尔值,指示时间戳是否出现在月末。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.DateOffset.copy

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.copy.html

DateOffset.copy()

返回频率的副本

例子

>>> freq = pd.DateOffset(1)
>>> freq_copy = freq.copy()
>>> freq is freq_copy
False 

pandas.tseries.offsets.DateOffset.is_anchored

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.is_anchored.html

DateOffset.is_anchored()

返回布尔值,指示频率是否为单位频率(n=1)。

自 2.2.0 版本起已弃用:is_anchored 已弃用,并将在未来版本中移除。请改用 obj.n == 1

示例

>>> pd.DateOffset().is_anchored()
True
>>> pd.DateOffset(2).is_anchored()
False 

pandas.tseries.offsets.DateOffset.is_on_offset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.is_on_offset.html

DateOffset.is_on_offset(dt)

返回时间戳是否与此频率相交的布尔值。

参数:

dtdatetime.datetime

用于检查与频率相交的时间戳。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Day(1)
>>> freq.is_on_offset(ts)
True 
>>> ts = pd.Timestamp(2022, 8, 6)
>>> ts.day_name()
'Saturday'
>>> freq = pd.offsets.BusinessDay(1)
>>> freq.is_on_offset(ts)
False 

pandas.tseries.offsets.DateOffset.is_month_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.is_month_start.html

DateOffset.is_month_start(ts)

返回布尔值,指示时间戳是否出现在月初。

例子

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.DateOffset.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.is_month_end.html

DateOffset.is_month_end(ts)

返回一个布尔值,指示时间戳是否出现在月末。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.DateOffset.is_quarter_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.is_quarter_start.html

DateOffset.is_quarter_start(ts)

返回一个布尔值,指示时间戳是否出现在季度开始。

Examples

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_start(ts)
True 

pandas.tseries.offsets.DateOffset.is_quarter_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.is_quarter_end.html

DateOffset.is_quarter_end(ts)

返回一个布尔值,指示时间戳是否发生在季度结束。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_end(ts)
False 

pandas.tseries.offsets.DateOffset.is_year_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.is_year_start.html

DateOffset.is_year_start(ts)

返回一个布尔值,表示时间戳是否发生在年初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_start(ts)
True 

pandas.tseries.offsets.DateOffset.is_year_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.DateOffset.is_year_end.html

DateOffset.is_year_end(ts)

返回时间戳是否发生在年末的布尔值。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_end(ts)
False 

pandas.tseries.offsets.BusinessDay

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.html

class pandas.tseries.offsets.BusinessDay

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

参数:

nint,默认为 1

表示的天数。

normalizebool,默认为 False

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

offsettimedelta,默认为 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 返回调用偏移对象的 n=1 和所有其他属性相等的副本。
calendar
freqstr 返回表示频率的字符串。
holidays
kwds 返回偏移的额外参数字典。
n
name 返回表示基础频率的字符串。
nanos
normalize
offset self._offset 的别名。
rule_code
weekmask

方法

copy() 返回频率的副本。
is_anchored() (已弃用) 返回频率是否为单位频率(n=1)的布尔值。
is_month_end(ts) 返回布尔值,指示时间戳是否在月末发生。
is_month_start(ts) 返回布尔值,指示时间戳是否在月初发生。
is_on_offset(dt) 返回布尔值,指示时间戳是否与此频率相交。
is_quarter_end(ts) 返回布尔值,指示时间戳是否在季度末发生。
is_quarter_start(ts) 返回布尔值,指示时间戳是否在季度初发生。
is_year_end(ts) 返回布尔值,指示时间戳是否在年末发生。
is_year_start(ts) 返回布尔值,指示时间戳是否在年初发生。
rollback(dt) 将提供的日期向上一个偏移量滚动,仅当不在偏移量上时。
rollforward(dt) 将提供的日期向下一个偏移量滚动,仅当不在偏移量上时。

pandas.tseries.offsets.BDay

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BDay.html

pandas.tseries.offsets.BDay

别名为BusinessDay

pandas.tseries.offsets.BusinessDay.freqstr

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.freqstr.html

BusinessDay.freqstr

返回表示频率的字符串。

示例

>>> pd.DateOffset(5).freqstr
'<5 * DateOffsets>' 
>>> pd.offsets.BusinessHour(2).freqstr
'2bh' 
>>> pd.offsets.Nano().freqstr
'ns' 
>>> pd.offsets.Nano(-3).freqstr
'-3ns' 

pandas.tseries.offsets.BusinessDay.kwds

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.kwds.html

BusinessDay.kwds

返回一个偏移量的额外参数字典。

示例

>>> pd.DateOffset(5).kwds
{} 
>>> pd.offsets.FY5253Quarter().kwds
{'weekday': 0,
 'startingMonth': 1,
 'qtr_with_extra_week': 1,
 'variation': 'nearest'} 

pandas.tseries.offsets.BusinessDay.name

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.name.html

BusinessDay.name

返回表示基础频率的字符串。

示例

>>> pd.offsets.Hour().name
'h' 
>>> pd.offsets.Hour(5).name
'h' 

pandas.tseries.offsets.BusinessDay.nanos

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.nanos.html

BusinessDay.nanos

pandas.tseries.offsets.BusinessDay.normalize

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.normalize.html

BusinessDay.normalize

pandas.tseries.offsets.BusinessDay.rule_code

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.rule_code.html

BusinessDay.rule_code

pandas.tseries.offsets.BusinessDay.n

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.n.html

BusinessDay.n

pandas.tseries.offsets.BusinessDay.weekmask

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.weekmask.html

BusinessDay.weekmask

pandas.tseries.offsets.BusinessDay.holidays

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.holidays.html

BusinessDay.holidays

pandas.tseries.offsets.BusinessDay.calendar

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.calendar.html

BusinessDay.calendar

pandas.tseries.offsets.BusinessDay.copy

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.copy.html

BusinessDay.copy()

返回频率的副本。

示例

>>> freq = pd.DateOffset(1)
>>> freq_copy = freq.copy()
>>> freq is freq_copy
False 

pandas.tseries.offsets.BusinessDay.is_anchored

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.is_anchored.html

BusinessDay.is_anchored()

返回布尔值,指示频率是否为单位频率(n=1)。

自 2.2.0 版本起已弃用:is_anchored 已弃用,并将在将来的版本中移除。请改用obj.n == 1

示例

>>> pd.DateOffset().is_anchored()
True
>>> pd.DateOffset(2).is_anchored()
False 

pandas.tseries.offsets.BusinessDay.is_on_offset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.is_on_offset.html

BusinessDay.is_on_offset(dt)

返回布尔值,指示时间戳是否与此频率相交。

参数:

dtdatetime.datetime

用于检查时间戳与频率的交集。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Day(1)
>>> freq.is_on_offset(ts)
True 
>>> ts = pd.Timestamp(2022, 8, 6)
>>> ts.day_name()
'Saturday'
>>> freq = pd.offsets.BusinessDay(1)
>>> freq.is_on_offset(ts)
False 

pandas.tseries.offsets.BusinessDay.is_month_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.is_month_start.html

BusinessDay.is_month_start(ts)

返回布尔值,指示时间戳是否发生在月初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.BusinessDay.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.is_month_end.html

BusinessDay.is_month_end(ts)

返回布尔值,指示时间戳是否出现在月末。

例子

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.BusinessDay.is_quarter_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.is_quarter_start.html

BusinessDay.is_quarter_start(ts)

返回布尔值,指示时间戳是否发生在季度开始。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_start(ts)
True 

pandas.tseries.offsets.BusinessDay.is_quarter_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.is_quarter_end.html

BusinessDay.is_quarter_end(ts)

返回布尔值,指示时间戳是否发生在季度结束。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_end(ts)
False 

pandas.tseries.offsets.BusinessDay.is_year_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.is_year_start.html

BusinessDay.is_year_start(ts)

返回时间戳是否发生在年初的布尔值。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_start(ts)
True 

pandas.tseries.offsets.BusinessDay.is_year_end

pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessDay.is_year_end.html

BusinessDay.is_year_end(ts)

返回一个布尔值,指示时间戳是否发生在年底。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_end(ts)
False 

pandas.tseries.offsets.BusinessHour

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.html

class pandas.tseries.offsets.BusinessHour

表示可能有 n 个工作小时的 DateOffset 子类。

参数:

n整数,默认为 1

代表的小时数。

normalizebool,默认为 False

在生成日期范围之前将开始/结束日期规范化为午夜。

startstr、时间或者 str/time 列表,默认为“09:00”

以 24 小时制表示你自定义工作小时的开始时间。

endstr、时间或者 str/time 列表,默认为“17:00”

以 24 小时制表示你自定义工作小时的结束时间。

offset时间增量,默认为 timedelta(0)

要应用的时间偏移量。

示例

你可以使用参数n来表示 n 小时的偏移量。

>>> ts = pd.Timestamp(2022, 12, 9, 8)
>>> ts + pd.offsets.BusinessHour(n=5)
Timestamp('2022-12-09 14:00:00') 

你也可以更改工作小时的开始和结束时间。

>>> ts = pd.Timestamp(2022, 8, 5, 16)
>>> ts + pd.offsets.BusinessHour(start="11:00")
Timestamp('2022-08-08 11:00:00') 
>>> from datetime import time as dt_time
>>> ts = pd.Timestamp(2022, 8, 5, 22)
>>> ts + pd.offsets.BusinessHour(end=dt_time(19, 0))
Timestamp('2022-08-08 10:00:00') 

通过将参数normalize设置为 True,你可以将下一个工作小时的开始时间调整到午夜。

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

你可以将你的工作日小时分成几部分。

>>> import datetime as dt
>>> freq = pd.offsets.BusinessHour(start=["06:00", "10:00", "15:00"],
...                                end=["08:00", "12:00", "17:00"])
>>> pd.date_range(dt.datetime(2022, 12, 9), dt.datetime(2022, 12, 13), freq=freq)
DatetimeIndex(['2022-12-09 06:00:00', '2022-12-09 07:00:00',
 '2022-12-09 10:00:00', '2022-12-09 11:00:00',
 '2022-12-09 15:00:00', '2022-12-09 16:00:00',
 '2022-12-12 06:00:00', '2022-12-12 07:00:00',
 '2022-12-12 10:00:00', '2022-12-12 11:00:00',
 '2022-12-12 15:00:00', '2022-12-12 16:00:00'],
 dtype='datetime64[ns]', freq='bh') 

属性

base 返回调用偏移对象的副本,其中 n=1,所有其他属性相等。
calendar
end
freqstr 返回表示频率的字符串。
holidays
kwds 返回偏移的额外参数字典。
n
name 返回表示基础频率的字符串。
nanos
next_bday 用于转移到下一个工作日。
normalize
offset self._offset 的别名。
rule_code
start
weekmask

方法

copy() 返回频率的副本。
is_anchored() (已废弃) 返回布尔值,指示频率是否为单位频率(n=1)。
is_month_end(ts) 返回布尔值,指示时间戳是否在月末发生。
is_month_start(ts) 返回布尔值,指示时间戳是否在月初发生。
is_on_offset(dt) 返回布尔值,指示时间戳是否与此频率相交。
is_quarter_end(ts) 返回布尔值,指示时间戳是否在季度结束时发生。
is_quarter_start(ts) 返回布尔值,指示时间戳是否在季度开始时发生。
is_year_end(ts) 返回布尔值,指示时间戳是否在年末发生。
is_year_start(ts) 返回布尔值,指示时间戳是否在年初发生。
rollback(other) 仅当不在偏移时,将提供的日期向后滚动到下一个偏移。
rollforward(other) 仅当不在偏移时,将提供的日期向前滚动到下一个偏移。

pandas.tseries.offsets.BusinessHour.freqstr

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.freqstr.html

BusinessHour.freqstr

返回表示频率的字符串。

示例

>>> pd.DateOffset(5).freqstr
'<5 * DateOffsets>' 
>>> pd.offsets.BusinessHour(2).freqstr
'2bh' 
>>> pd.offsets.Nano().freqstr
'ns' 
>>> pd.offsets.Nano(-3).freqstr
'-3ns' 

pandas.tseries.offsets.BusinessHour.kwds

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.kwds.html

BusinessHour.kwds

返回一个偏移量的额外参数字典。

示例

>>> pd.DateOffset(5).kwds
{} 
>>> pd.offsets.FY5253Quarter().kwds
{'weekday': 0,
 'startingMonth': 1,
 'qtr_with_extra_week': 1,
 'variation': 'nearest'} 

pandas.tseries.offsets.BusinessHour.name

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.name.html

BusinessHour.name

返回表示基本频率的字符串。

Examples

>>> pd.offsets.Hour().name
'h' 
>>> pd.offsets.Hour(5).name
'h' 

pandas.tseries.offsets.BusinessHour.nanos

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.nanos.html

BusinessHour.nanos

pandas.tseries.offsets.BusinessHour.normalize

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.normalize.html

BusinessHour.normalize

pandas.tseries.offsets.BusinessHour.rule_code

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.rule_code.html

BusinessHour.rule_code

pandas.tseries.offsets.BusinessHour.n

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.n.html

BusinessHour.n

pandas.tseries.offsets.BusinessHour.start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.start.html

BusinessHour.start

pandas.tseries.offsets.BusinessHour.end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.end.html

BusinessHour.end

pandas.tseries.offsets.BusinessHour.weekmask

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.weekmask.html

BusinessHour.weekmask

pandas.tseries.offsets.BusinessHour.holidays

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.holidays.html

BusinessHour.holidays

pandas.tseries.offsets.BusinessHour.calendar

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.calendar.html

BusinessHour.calendar

pandas.tseries.offsets.BusinessHour.copy

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.copy.html

BusinessHour.copy()

返回频率的副本。

示例

>>> freq = pd.DateOffset(1)
>>> freq_copy = freq.copy()
>>> freq is freq_copy
False 

pandas.tseries.offsets.BusinessHour.is_anchored

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.is_anchored.html

BusinessHour.is_anchored()

返回布尔值,指示频率是否为单位频率(n=1)。

自 2.2.0 版本起已废弃:is_anchored 已弃用,并将在将来的版本中移除。请改用obj.n == 1

示例

>>> pd.DateOffset().is_anchored()
True
>>> pd.DateOffset(2).is_anchored()
False 

pandas.tseries.offsets.BusinessHour.is_on_offset

pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.is_on_offset.html

BusinessHour.is_on_offset(dt)

返回布尔值,指示时间戳是否与此频率相交。

参数:

dtdatetime.datetime

用于检查与频率交集的时间戳。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Day(1)
>>> freq.is_on_offset(ts)
True 
>>> ts = pd.Timestamp(2022, 8, 6)
>>> ts.day_name()
'Saturday'
>>> freq = pd.offsets.BusinessDay(1)
>>> freq.is_on_offset(ts)
False 

pandas.tseries.offsets.BusinessHour.is_month_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.is_month_start.html

BusinessHour.is_month_start(ts)

返回一个布尔值,指示时间戳是否出现在月初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.BusinessHour.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.is_month_end.html

BusinessHour.is_month_end(ts)

返回布尔值,指示时间戳是否发生在月末。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.BusinessHour.is_quarter_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.is_quarter_start.html

BusinessHour.is_quarter_start(ts)

返回布尔值,指示时间戳是否发生在季度开始。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_start(ts)
True 

pandas.tseries.offsets.BusinessHour.is_quarter_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.is_quarter_end.html

BusinessHour.is_quarter_end(ts)

返回布尔值,指示时间戳是否为季度结束。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_end(ts)
False 

pandas.tseries.offsets.BusinessHour.is_year_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.is_year_start.html

BusinessHour.is_year_start(ts)

返回一个布尔值,指示时间戳是否发生在年初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_start(ts)
True 

pandas.tseries.offsets.BusinessHour.is_year_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessHour.is_year_end.html

BusinessHour.is_year_end(ts)

返回一个布尔值,表示时间戳是否出现在年底。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_end(ts)
False 

pandas.tseries.offsets.CustomBusinessDay

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.html

class pandas.tseries.offsets.CustomBusinessDay

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

在 CustomBusinessDay 中,我们可以使用自定义的 weekmask、holidays 和 calendar。

参数:

nint,默认值为 1

表示的天数。

normalizebool,默认值为 False

在生成日期范围之前,将开始/结束日期规范化为午夜。

weekmaskstr,默认值为‘Mon Tue Wed Thu Fri’

有效工作日的 weekmask,传递给numpy.busdaycalendar

holidayslist

要从有效工作日集合中排除的日期列表/数组,传递给numpy.busdaycalendar

calendarnp.busdaycalendar

要集成的日历。

offsettimedelta,默认值为 timedelta(0)

要应用的时间偏移。

示例

在下面的示例中,默认参数给出了下一个工作日。

>>> ts = pd.Timestamp(2022, 8, 5, 16)
>>> ts + pd.offsets.CustomBusinessDay()
Timestamp('2022-08-08 16:00:00') 

工作日可以通过weekmask参数指定。在下一个示例中,使用函数 strftime()将返回的日期时间对象转换为其字符串表示形式。

>>> import datetime as dt
>>> freq = pd.offsets.CustomBusinessDay(weekmask="Mon Wed Fri")
>>> pd.date_range(dt.datetime(2022, 12, 10), dt.datetime(2022, 12, 21),
...               freq=freq).strftime('%a  %d %b %Y %H:%M')
Index(['Mon 12 Dec 2022 00:00', 'Wed 14 Dec 2022 00:00',
 'Fri 16 Dec 2022 00:00', 'Mon 19 Dec 2022 00:00',
 'Wed 21 Dec 2022 00:00'],
 dtype='object') 

使用 NumPy 工作日日历,您可以定义自定义假期。

>>> import datetime as dt
>>> bdc = np.busdaycalendar(holidays=['2022-12-12', '2022-12-14'])
>>> freq = pd.offsets.CustomBusinessDay(calendar=bdc)
>>> pd.date_range(dt.datetime(2022, 12, 10), dt.datetime(2022, 12, 25), freq=freq)
DatetimeIndex(['2022-12-13', '2022-12-15', '2022-12-16', '2022-12-19',
 '2022-12-20', '2022-12-21', '2022-12-22', '2022-12-23'],
 dtype='datetime64[ns]', freq='C') 

如果您想将结果向前或向后移动 n 天,可以使用参数offset

>>> pd.Timestamp(2022, 8, 5, 16) + pd.offsets.CustomBusinessDay(1)
Timestamp('2022-08-08 16:00:00') 
>>> import datetime as dt
>>> ts = pd.Timestamp(2022, 8, 5, 16)
>>> ts + pd.offsets.CustomBusinessDay(1, offset=dt.timedelta(days=1))
Timestamp('2022-08-09 16:00:00') 

属性

base 返回调用偏移对象的副本,其中 n=1,所有其他属性相等。
calendar
freqstr 返回表示频率的字符串。
holidays
kwds 返回偏移的额外参数的字典。
n
name 返回表示基本频率的字符串。
nanos
normalize
offset self._offset 的别名。
rule_code
weekmask

方法

copy() 返回频率的副本。
is_anchored() (已弃用)返回频率是否为单位频率(n=1)的布尔值。
is_month_end(ts) 返回时间戳是否在月末发生的布尔值。
is_month_start(ts) 返回时间戳是否在月初发生的布尔值。
is_on_offset(dt) 返回时间戳是否与此频率相交的布尔值。
is_quarter_end(ts) 返回时间戳是否在季度结束时发生的布尔值。
is_quarter_start(ts) 返回时间戳是否在季度开始时发生的布尔值。
is_year_end(ts) 返回时间戳是否在年底发生的布尔值。
is_year_start(ts) 返回时间戳是否在年初发生的布尔值。
rollback(dt) 仅当不在偏移量上时,将提供的日期向后滚动到下一个偏移量。
rollforward(dt) 仅当不在偏移量上时,将提供的日期向前滚动到下一个偏移量。

pandas.tseries.offsets.CDay

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CDay.html

pandas.tseries.offsets.CDay

CustomBusinessDay的别名

pandas.tseries.offsets.CustomBusinessDay.freqstr

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.freqstr.html

CustomBusinessDay.freqstr

返回表示频率的字符串。

例子

>>> pd.DateOffset(5).freqstr
'<5 * DateOffsets>' 
>>> pd.offsets.BusinessHour(2).freqstr
'2bh' 
>>> pd.offsets.Nano().freqstr
'ns' 
>>> pd.offsets.Nano(-3).freqstr
'-3ns' 

pandas.tseries.offsets.CustomBusinessDay.kwds

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.kwds.html

CustomBusinessDay.kwds

返回偏移量的额外参数字典。

示例

>>> pd.DateOffset(5).kwds
{} 
>>> pd.offsets.FY5253Quarter().kwds
{'weekday': 0,
 'startingMonth': 1,
 'qtr_with_extra_week': 1,
 'variation': 'nearest'} 

pandas.tseries.offsets.CustomBusinessDay.name

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.name.html

CustomBusinessDay.name

返回表示基础频率的字符串。

示例

>>> pd.offsets.Hour().name
'h' 
>>> pd.offsets.Hour(5).name
'h' 

pandas.tseries.offsets.CustomBusinessDay.nanos

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.nanos.html

CustomBusinessDay.nanos

pandas.tseries.offsets.CustomBusinessDay.normalize

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.normalize.html

CustomBusinessDay.normalize

pandas.tseries.offsets.CustomBusinessDay.rule_code

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.rule_code.html

CustomBusinessDay.rule_code

pandas.tseries.offsets.CustomBusinessDay.n

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.n.html

CustomBusinessDay.n

pandas.tseries.offsets.CustomBusinessDay.weekmask

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.weekmask.html

CustomBusinessDay.weekmask

pandas.tseries.offsets.CustomBusinessDay.calendar

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.calendar.html

CustomBusinessDay.calendar

pandas.tseries.offsets.CustomBusinessDay.holidays

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.holidays.html

CustomBusinessDay.holidays

pandas.tseries.offsets.CustomBusinessDay.copy

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.copy.html

CustomBusinessDay.copy()

返回频率的副本。

示例

>>> freq = pd.DateOffset(1)
>>> freq_copy = freq.copy()
>>> freq is freq_copy
False 

pandas.tseries.offsets.CustomBusinessDay.is_anchored

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.is_anchored.html

CustomBusinessDay.is_anchored()

返回布尔值,指示频率是否为单位频率(n=1)。

自版本 2.2.0 起已弃用:is_anchored 已弃用,并将在将来的版本中移除。请改用obj.n == 1

示例

>>> pd.DateOffset().is_anchored()
True
>>> pd.DateOffset(2).is_anchored()
False 

pandas.tseries.offsets.CustomBusinessDay.is_on_offset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.is_on_offset.html

CustomBusinessDay.is_on_offset(dt)

返回布尔值,指示时间戳是否与此频率相交。

参数:

dtdatetime.datetime

用于检查时间戳与频率的交集。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Day(1)
>>> freq.is_on_offset(ts)
True 
>>> ts = pd.Timestamp(2022, 8, 6)
>>> ts.day_name()
'Saturday'
>>> freq = pd.offsets.BusinessDay(1)
>>> freq.is_on_offset(ts)
False 

pandas.tseries.offsets.CustomBusinessDay.is_month_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.is_month_start.html

CustomBusinessDay.is_month_start(ts)

返回一个布尔值,指示时间戳是否出现在月初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.CustomBusinessDay.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.is_month_end.html

CustomBusinessDay.is_month_end(ts)

返回布尔值,表示时间戳是否出现在月末。

举例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.CustomBusinessDay.is_quarter_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.is_quarter_start.html

CustomBusinessDay.is_quarter_start(ts)

返回布尔值,指示时间戳是否出现在季度开始。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_start(ts)
True 

pandas.tseries.offsets.CustomBusinessDay.is_quarter_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.is_quarter_end.html

CustomBusinessDay.is_quarter_end(ts)

返回时间戳是否发生在季末。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_end(ts)
False 

pandas.tseries.offsets.CustomBusinessDay.is_year_start

pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.is_year_start.html

CustomBusinessDay.is_year_start(ts)

返回一个布尔值,指示时间戳是否发生在年初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_start(ts)
True 

pandas.tseries.offsets.CustomBusinessDay.is_year_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessDay.is_year_end.html

CustomBusinessDay.is_year_end(ts)

返回一个布尔值,指示时间戳是否发生在年末。

例子

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_end(ts)
False 

pandas.tseries.offsets.CustomBusinessHour

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.html

class pandas.tseries.offsets.CustomBusinessHour

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

在 CustomBusinessHour 中,我们可以使用自定义的 weekmask、holidays 和 calendar。

参数:

n整数,默认值为 1

表示的小时数。

normalize布尔值,默认为 False

在生成日期范围之前将起始/结束日期归一化为午夜。

weekmask字符串,默认值为 'Mon Tue Wed Thu Fri'

有效工作日的 weekmask,传递给 numpy.busdaycalendar

holidays列表

要从有效工作日集中排除的日期列表/数组,传递给 numpy.busdaycalendar

calendarnp.busdaycalendar

要集成的日历。

start字符串、时间或字符串/时间列表,默认值为 “09:00”

你自定义的工作小时开始时间,以 24 小时制表示。

end字符串、时间或字符串/时间列表,默认值为:“17:00”

你自定义的工作小时结束时间,以 24 小时制表示。

offset时间增量,默认 timedelta(0)

要应用的时间偏移量。

示例

在下面的示例中,默认参数给出了下一个工作小时。

>>> ts = pd.Timestamp(2022, 8, 5, 16)
>>> ts + pd.offsets.CustomBusinessHour()
Timestamp('2022-08-08 09:00:00') 

我们也可以更改工作小时的开始和结束时间。

>>> ts = pd.Timestamp(2022, 8, 5, 16)
>>> ts + pd.offsets.CustomBusinessHour(start="11:00")
Timestamp('2022-08-08 11:00:00') 
>>> from datetime import time as dt_time
>>> ts = pd.Timestamp(2022, 8, 5, 16)
>>> ts + pd.offsets.CustomBusinessHour(end=dt_time(19, 0))
Timestamp('2022-08-05 17:00:00') 
>>> ts = pd.Timestamp(2022, 8, 5, 22)
>>> ts + pd.offsets.CustomBusinessHour(end=dt_time(19, 0))
Timestamp('2022-08-08 10:00:00') 

你可以将工作日的小时分成几部分。

>>> import datetime as dt
>>> freq = pd.offsets.CustomBusinessHour(start=["06:00", "10:00", "15:00"],
...                                      end=["08:00", "12:00", "17:00"])
>>> pd.date_range(dt.datetime(2022, 12, 9), dt.datetime(2022, 12, 13), freq=freq)
DatetimeIndex(['2022-12-09 06:00:00', '2022-12-09 07:00:00',
 '2022-12-09 10:00:00', '2022-12-09 11:00:00',
 '2022-12-09 15:00:00', '2022-12-09 16:00:00',
 '2022-12-12 06:00:00', '2022-12-12 07:00:00',
 '2022-12-12 10:00:00', '2022-12-12 11:00:00',
 '2022-12-12 15:00:00', '2022-12-12 16:00:00'],
 dtype='datetime64[ns]', freq='cbh') 

可以通过 weekmask 参数指定工作日。要将返回的 datetime 对象转换为其字符串表示形式,下一个示例中使用了函数 strftime()。

>>> import datetime as dt
>>> freq = pd.offsets.CustomBusinessHour(weekmask="Mon Wed Fri",
...                                      start="10:00", end="13:00")
>>> pd.date_range(dt.datetime(2022, 12, 10), dt.datetime(2022, 12, 18),
...               freq=freq).strftime('%a  %d %b %Y %H:%M')
Index(['Mon 12 Dec 2022 10:00', 'Mon 12 Dec 2022 11:00',
 'Mon 12 Dec 2022 12:00', 'Wed 14 Dec 2022 10:00',
 'Wed 14 Dec 2022 11:00', 'Wed 14 Dec 2022 12:00',
 'Fri 16 Dec 2022 10:00', 'Fri 16 Dec 2022 11:00',
 'Fri 16 Dec 2022 12:00'],
 dtype='object') 

使用 NumPy 工作日日历,你可以定义自定义的假期。

>>> import datetime as dt
>>> bdc = np.busdaycalendar(holidays=['2022-12-12', '2022-12-14'])
>>> freq = pd.offsets.CustomBusinessHour(calendar=bdc, start="10:00", end="13:00")
>>> pd.date_range(dt.datetime(2022, 12, 10), dt.datetime(2022, 12, 18), freq=freq)
DatetimeIndex(['2022-12-13 10:00:00', '2022-12-13 11:00:00',
 '2022-12-13 12:00:00', '2022-12-15 10:00:00',
 '2022-12-15 11:00:00', '2022-12-15 12:00:00',
 '2022-12-16 10:00:00', '2022-12-16 11:00:00',
 '2022-12-16 12:00:00'],
 dtype='datetime64[ns]', freq='cbh') 

属性

base 返回调用偏移对象的副本,其中 n=1,所有其他属性相等。
calendar
end
freqstr 返回表示频率的字符串。
holidays
kwds 返回偏移的额外参数的字典。
n
name 返回表示基本频率的字符串。
nanos
next_bday 用于移动到下一个工作日。
normalize
offset self._offset 的别名。
rule_code
start
weekmask

方法

copy() 返回频率的副本。
is_anchored() (已弃用) 返回一个布尔值,指示频率是否为单位频率(n=1)。
is_month_end(ts) 返回一个布尔值,指示时间戳是否出现在月末。
is_month_start(ts) 返回一个布尔值,指示时间戳是否出现在月初。
is_on_offset(dt) 返回一个布尔值,指示时间戳是否与此频率相交。
is_quarter_end(ts) 返回一个布尔值,指示时间戳是否出现在季度末。
is_quarter_start(ts) 返回一个布尔值,指示时间戳是否出现在季度初。
is_year_end(ts) 返回一个布尔值,指示时间戳是否发生在年末。
is_year_start(ts) 返回一个布尔值,指示时间戳是否发生在年初。
rollback(other) 将提供的日期向后滚动到下一个偏移量,仅当不在偏移量上时。
rollforward(other) 将提供的日期向前滚动到下一个偏移量,仅当不在偏移量上时。

pandas.tseries.offsets.CustomBusinessHour.freqstr

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.freqstr.html

CustomBusinessHour.freqstr

返回表示频率的字符串。

示例

>>> pd.DateOffset(5).freqstr
'<5 * DateOffsets>' 
>>> pd.offsets.BusinessHour(2).freqstr
'2bh' 
>>> pd.offsets.Nano().freqstr
'ns' 
>>> pd.offsets.Nano(-3).freqstr
'-3ns' 

pandas.tseries.offsets.CustomBusinessHour.kwds

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.kwds.html

CustomBusinessHour.kwds

返回偏移量的额外参数字典。

示例

>>> pd.DateOffset(5).kwds
{} 
>>> pd.offsets.FY5253Quarter().kwds
{'weekday': 0,
 'startingMonth': 1,
 'qtr_with_extra_week': 1,
 'variation': 'nearest'} 

pandas.tseries.offsets.CustomBusinessHour.name

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.name.html

CustomBusinessHour.name

返回表示基本频率的字符串。

示例

>>> pd.offsets.Hour().name
'h' 
>>> pd.offsets.Hour(5).name
'h' 

pandas.tseries.offsets.CustomBusinessHour.nanos

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.nanos.html

CustomBusinessHour.nanos

pandas.tseries.offsets.CustomBusinessHour.normalize

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.normalize.html

CustomBusinessHour.normalize

pandas.tseries.offsets.CustomBusinessHour.rule_code

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.rule_code.html

CustomBusinessHour.rule_code

pandas.tseries.offsets.CustomBusinessHour.n

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.n.html

CustomBusinessHour.n

pandas.tseries.offsets.CustomBusinessHour.weekmask

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.weekmask.html

CustomBusinessHour.weekmask

pandas.tseries.offsets.CustomBusinessHour.calendar

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.calendar.html

CustomBusinessHour.calendar

pandas.tseries.offsets.CustomBusinessHour.holidays

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.holidays.html

CustomBusinessHour.holidays

pandas.tseries.offsets.CustomBusinessHour.start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.start.html

CustomBusinessHour.start

pandas.tseries.offsets.CustomBusinessHour.end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.end.html

CustomBusinessHour.end

pandas.tseries.offsets.CustomBusinessHour.copy

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.copy.html

CustomBusinessHour.copy()

返回频率的副本。

示例

>>> freq = pd.DateOffset(1)
>>> freq_copy = freq.copy()
>>> freq is freq_copy
False 

pandas.tseries.offsets.CustomBusinessHour.is_anchored

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.is_anchored.html

CustomBusinessHour.is_anchored()

返回布尔值,指示频率是否为单位频率(n=1)。

自版本 2.2.0 起已废弃:is_anchored 已废弃,并将在将来的版本中移除。请改用 obj.n == 1

示例

>>> pd.DateOffset().is_anchored()
True
>>> pd.DateOffset(2).is_anchored()
False 

pandas.tseries.offsets.CustomBusinessHour.is_on_offset

原文

CustomBusinessHour.is_on_offset(dt)

返回布尔值,指示时间戳是否与此频率相交。

参数:

dtdatetime.datetime

要检查与频率相交的时间戳。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Day(1)
>>> freq.is_on_offset(ts)
True 
>>> ts = pd.Timestamp(2022, 8, 6)
>>> ts.day_name()
'Saturday'
>>> freq = pd.offsets.BusinessDay(1)
>>> freq.is_on_offset(ts)
False 

pandas.tseries.offsets.CustomBusinessHour.is_month_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.is_month_start.html

CustomBusinessHour.is_month_start(ts)

返回布尔值,判断时间戳是否出现在月初。

例子

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.CustomBusinessHour.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.is_month_end.html

CustomBusinessHour.is_month_end(ts)

返回一个布尔值,指示时间戳是否发生在月末。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.CustomBusinessHour.is_quarter_start

pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.is_quarter_start.html

CustomBusinessHour.is_quarter_start(ts)

返回一个布尔值,指示时间戳是否出现在季度开始。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_start(ts)
True 

pandas.tseries.offsets.CustomBusinessHour.is_quarter_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.is_quarter_end.html

CustomBusinessHour.is_quarter_end(ts)

返回布尔值,表示时间戳是否发生在季末。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_end(ts)
False 

pandas.tseries.offsets.CustomBusinessHour.is_year_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.is_year_start.html

CustomBusinessHour.is_year_start(ts)

返回布尔值,指示时间戳是否发生在年初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_start(ts)
True 

pandas.tseries.offsets.CustomBusinessHour.is_year_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessHour.is_year_end.html

CustomBusinessHour.is_year_end(ts)

返回时间戳是否发生在年底的布尔值。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_end(ts)
False 

pandas.tseries.offsets.MonthEnd

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.html

class pandas.tseries.offsets.MonthEnd

一个月末的日期偏移。

MonthEnd 跳转到下一个月末的日期。

参数:

nint,默认为 1

表示的月份数。

normalizebool,默认为 False

在生成日期范围之前,将开始/结束日期标准化为午夜。

另请参阅

DateOffset

标准的日期增量类型。

示例

>>> ts = pd.Timestamp(2022, 1, 30)
>>> ts + pd.offsets.MonthEnd()
Timestamp('2022-01-31 00:00:00') 
>>> ts = pd.Timestamp(2022, 1, 31)
>>> ts + pd.offsets.MonthEnd()
Timestamp('2022-02-28 00:00:00') 

如果你想要获取当前月份的月末:

>>> ts = pd.Timestamp(2022, 1, 31)
>>> pd.offsets.MonthEnd().rollforward(ts)
Timestamp('2022-01-31 00:00:00') 

属性

base 返回调用偏移对象的副本,其中 n=1,所有其他属性相等。
freqstr 返回表示频率的字符串。
kwds 返回偏移的额外参数的字典。
n
name 返回表示基本频率的字符串。
nanos
normalize
rule_code

方法

copy() 返回频率的副本。
is_anchored() (已弃用)返回频率是否是单位频率(n=1)的布尔值。
is_month_end(ts) 返回时间戳是否发生在月末的布尔值。
is_month_start(ts) 返回时间戳是否发生在月初的布尔值。
is_on_offset(dt) 返回一个布尔值,指示时间戳是否与此频率相交。
is_quarter_end(ts) 返回一个布尔值,指示时间戳是否在季度结束时发生。
is_quarter_start(ts) 返回一个布尔值,指示时间戳是否在季度开始时发生。
is_year_end(ts) 返回一个布尔值,指示时间戳是否在年末发生。
is_year_start(ts) 返回一个布尔值,指示时间戳是否在年初发生。
rollback(dt) 仅当不在偏移量上时,将提供的日期向后滚动到下一个偏移量。
rollforward(dt) 仅当不在偏移量上时,将提供的日期向前滚动到下一个偏移量。

pandas.tseries.offsets.MonthEnd.freqstr

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.freqstr.html

MonthEnd.freqstr

返回表示频率的字符串。

示例

>>> pd.DateOffset(5).freqstr
'<5 * DateOffsets>' 
>>> pd.offsets.BusinessHour(2).freqstr
'2bh' 
>>> pd.offsets.Nano().freqstr
'ns' 
>>> pd.offsets.Nano(-3).freqstr
'-3ns' 

pandas.tseries.offsets.MonthEnd.kwds

原文链接

MonthEnd.kwds

返回偏移量的额外参数字典。

示例

>>> pd.DateOffset(5).kwds
{} 
>>> pd.offsets.FY5253Quarter().kwds
{'weekday': 0,
 'startingMonth': 1,
 'qtr_with_extra_week': 1,
 'variation': 'nearest'} 

pandas.tseries.offsets.MonthEnd.name

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.name.html

MonthEnd.name

返回表示基本频率的字符串。

示例

>>> pd.offsets.Hour().name
'h' 
>>> pd.offsets.Hour(5).name
'h' 

pandas.tseries.offsets.MonthEnd.nanos

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.nanos.html

MonthEnd.nanos

pandas.tseries.offsets.MonthEnd.normalize

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.normalize.html

MonthEnd.normalize

pandas.tseries.offsets.MonthEnd.rule_code

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.rule_code.html

MonthEnd.rule_code

pandas.tseries.offsets.MonthEnd.n

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.n.html

MonthEnd.n

pandas.tseries.offsets.MonthEnd.copy

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.copy.html

MonthEnd.copy()

返回频率的副本。

示例

>>> freq = pd.DateOffset(1)
>>> freq_copy = freq.copy()
>>> freq is freq_copy
False 

pandas.tseries.offsets.MonthEnd.is_anchored

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.is_anchored.html

MonthEnd.is_anchored()

返回布尔值,指示频率是否为单位频率(n=1)。

从版本 2.2.0 起弃用:is_anchored 已弃用,将在将来的版本中删除。请使用 obj.n == 1 代替。

示例

>>> pd.DateOffset().is_anchored()
True
>>> pd.DateOffset(2).is_anchored()
False 

pandas.tseries.offsets.MonthEnd.is_on_offset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.is_on_offset.html

MonthEnd.is_on_offset(dt)

返回布尔值,指示时间戳是否与此频率相交。

参数:

dtdatetime.datetime

要检查与频率交集的时间戳。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Day(1)
>>> freq.is_on_offset(ts)
True 
>>> ts = pd.Timestamp(2022, 8, 6)
>>> ts.day_name()
'Saturday'
>>> freq = pd.offsets.BusinessDay(1)
>>> freq.is_on_offset(ts)
False 

pandas.tseries.offsets.MonthEnd.is_month_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.is_month_start.html

MonthEnd.is_month_start(ts)

返回布尔值,指示时间戳是否出现在月初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.MonthEnd.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.is_month_end.html

MonthEnd.is_month_end(ts)

返回布尔值,指示时间戳是否出现在月末。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.MonthEnd.is_quarter_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.is_quarter_start.html

MonthEnd.is_quarter_start(ts)

返回布尔值,指示时间戳是否出现在季度开始。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_start(ts)
True 

pandas.tseries.offsets.MonthEnd.is_quarter_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.is_quarter_end.html

MonthEnd.is_quarter_end(ts)

返回布尔值,指示时间戳是否发生在季度结束。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_end(ts)
False 

pandas.tseries.offsets.MonthEnd.is_year_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.is_year_start.html

MonthEnd.is_year_start(ts)

返回一个布尔值,指示时间戳是否出现在年初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_start(ts)
True 

pandas.tseries.offsets.MonthEnd.is_year_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthEnd.is_year_end.html

MonthEnd.is_year_end(ts)

返回时间戳是否发生在年底的布尔值。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_end(ts)
False 

pandas.tseries.offsets.MonthBegin

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.html

class pandas.tseries.offsets.MonthBegin

一个月的开始的 DateOffset。

MonthBegin 转到下一个月初的日期。

参数:

nint,默认为 1

表示的月份数。

normalizebool,默认为 False

在生成日期范围之前将开始/结束日期规范化为午夜。

另请参阅

DateOffset

标准的日期增量类型。

示例

>>> ts = pd.Timestamp(2022, 11, 30)
>>> ts + pd.offsets.MonthBegin()
Timestamp('2022-12-01 00:00:00') 
>>> ts = pd.Timestamp(2022, 12, 1)
>>> ts + pd.offsets.MonthBegin()
Timestamp('2023-01-01 00:00:00') 

如果您想获取当前月份的开始:

>>> ts = pd.Timestamp(2022, 12, 1)
>>> pd.offsets.MonthBegin().rollback(ts)
Timestamp('2022-12-01 00:00:00') 

属性

base 返回调用偏移对象的副本,其中 n=1,所有其他属性相等。
freqstr 返回表示频率的字符串。
kwds 返回偏移的额外参数字典。
n
name 返回表示基本频率的字符串。
nanos
normalize
rule_code

方法

copy() 返回频率的副本。
is_anchored() (已弃用) 返回频率是否为单位频率(n=1)的布尔值。
is_month_end(ts) 返回时间戳是否发生在月末的布尔值。
is_month_start(ts) 返回时间戳是否发生在月初的布尔值。
is_on_offset(dt) 返回一个布尔值,指示时间戳是否与此频率相交。
is_quarter_end(ts) 返回一个布尔值,指示时间戳是否出现在季度末。
is_quarter_start(ts) 返回一个布尔值,指示时间戳是否出现在季度初。
is_year_end(ts) 返回一个布尔值,指示时间戳是否出现在年末。
is_year_start(ts) 返回一个布尔值,指示时间戳是否出现在年初。
rollback(dt) 仅当不在偏移量上时,将提供的日期向后滚动到下一个偏移量。
rollforward(dt) 仅当不在偏移量上时,将提供的日期向前滚动到下一个偏移量。

pandas.tseries.offsets.MonthBegin.freqstr

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.freqstr.html

MonthBegin.freqstr

返回表示频率的字符串。

示例

>>> pd.DateOffset(5).freqstr
'<5 * DateOffsets>' 
>>> pd.offsets.BusinessHour(2).freqstr
'2bh' 
>>> pd.offsets.Nano().freqstr
'ns' 
>>> pd.offsets.Nano(-3).freqstr
'-3ns' 

pandas.tseries.offsets.MonthBegin.kwds

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.kwds.html

MonthBegin.kwds

返回偏移量的额外参数字典。

示例

>>> pd.DateOffset(5).kwds
{} 
>>> pd.offsets.FY5253Quarter().kwds
{'weekday': 0,
 'startingMonth': 1,
 'qtr_with_extra_week': 1,
 'variation': 'nearest'} 

pandas.tseries.offsets.MonthBegin.name

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.name.html

MonthBegin.name

返回表示基本频率的字符串。

举例

>>> pd.offsets.Hour().name
'h' 
>>> pd.offsets.Hour(5).name
'h' 

pandas.tseries.offsets.MonthBegin.nanos

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.nanos.html

MonthBegin.nanos

pandas.tseries.offsets.MonthBegin.normalize

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.normalize.html

MonthBegin.normalize

pandas.tseries.offsets.MonthBegin.rule_code

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.rule_code.html

MonthBegin.rule_code

pandas.tseries.offsets.MonthBegin.n

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.n.html

MonthBegin.n

pandas.tseries.offsets.MonthBegin.copy

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.copy.html

MonthBegin.copy()

返回频率的一个副本。

示例

>>> freq = pd.DateOffset(1)
>>> freq_copy = freq.copy()
>>> freq is freq_copy
False 

pandas.tseries.offsets.MonthBegin.is_anchored

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.is_anchored.html

MonthBegin.is_anchored()

返回布尔值,指示频率是否为单位频率(n=1)。

自版本 2.2.0 起已弃用:is_anchored 已弃用,并将在将来的版本中移除。请改用obj.n == 1

示例

>>> pd.DateOffset().is_anchored()
True
>>> pd.DateOffset(2).is_anchored()
False 

pandas.tseries.offsets.MonthBegin.is_on_offset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.is_on_offset.html

MonthBegin.is_on_offset(dt)

返回布尔值,指示时间戳是否与此频率相交。

参数:

dtdatetime.datetime

要检查与频率相交的时间戳。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Day(1)
>>> freq.is_on_offset(ts)
True 
>>> ts = pd.Timestamp(2022, 8, 6)
>>> ts.day_name()
'Saturday'
>>> freq = pd.offsets.BusinessDay(1)
>>> freq.is_on_offset(ts)
False 

pandas.tseries.offsets.MonthBegin.is_month_start

pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.is_month_start.html

MonthBegin.is_month_start(ts)

返回一个布尔值,指示时间戳是否出现在月初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.MonthBegin.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.is_month_end.html

MonthBegin.is_month_end(ts)

返回一个布尔值,指示时间戳是否出现在月末。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.MonthBegin.is_quarter_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.is_quarter_start.html

MonthBegin.is_quarter_start(ts)

返回布尔值,指示时间戳是否发生在季度开始。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_start(ts)
True 

pandas.tseries.offsets.MonthBegin.is_quarter_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.is_quarter_end.html

MonthBegin.is_quarter_end(ts)

返回一个布尔值,指示时间戳是否发生在季度结束。

Examples

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_end(ts)
False 

pandas.tseries.offsets.MonthBegin.is_year_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.is_year_start.html

MonthBegin.is_year_start(ts)

返回一个布尔值,指示时间戳是否出现在年初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_start(ts)
True 

pandas.tseries.offsets.MonthBegin.is_year_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.MonthBegin.is_year_end.html

MonthBegin.is_year_end(ts)

返回一个布尔值,指示时间戳是否发生在年底。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_end(ts)
False 

pandas.tseries.offsets.BusinessMonthEnd

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.html

class pandas.tseries.offsets.BusinessMonthEnd

DateOffset 在月末的最后一个工作日之间增加。

BusinessMonthEnd 跳转到下一个日期,即当月的最后一个工作日。

参数:

n整���,默认为 1

表示的月份数。

normalize布尔值,默认为 False

将开始/结束日期归一化为午夜,然后生成日期范围。

另请参见

DateOffset

标准日期增量类型。

示例

>>> ts = pd.Timestamp(2022, 11, 29)
>>> ts + pd.offsets.BMonthEnd()
Timestamp('2022-11-30 00:00:00') 
>>> ts = pd.Timestamp(2022, 11, 30)
>>> ts + pd.offsets.BMonthEnd()
Timestamp('2022-12-30 00:00:00') 

如果要获取当前工作月的结束日期:

>>> ts = pd.Timestamp(2022, 11, 30)
>>> pd.offsets.BMonthEnd().rollforward(ts)
Timestamp('2022-11-30 00:00:00') 

属性

base 返回调用偏移量对象的副本,其中 n=1,所有其他属性相等。
freqstr 返回表示频率的字符串。
kwds 返回偏移量的额外参数字典。
n
name 返回表示基础频率的字符串。
nanos
normalize
rule_code

方法

copy() 返回频率的副本。
is_anchored() (已弃用) 返回频率是否为单位频率(n=1)的布尔值。
is_month_end(ts) 返回时间戳是否在月末发生的布尔值。
is_month_start(ts) 返回时间戳是否在月初。
is_on_offset(dt) 返回时间戳是否与此频率相交。
is_quarter_end(ts) 返回时间戳是否在季末。
is_quarter_start(ts) 返回时间戳是否在季初。
is_year_end(ts) 返回时间戳是否在年末。
is_year_start(ts) 返回时间戳是否在年初。
rollback(dt) 仅在不在偏移量上时将提供的日期回滚到下一个偏移量。
rollforward(dt) 仅在不在偏移量上时将提供的日期向前滚动到下一个偏移量。

pandas.tseries.offsets.BMonthEnd

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BMonthEnd.html

pandas.tseries.offsets.BMonthEnd

别名为BusinessMonthEnd

pandas.tseries.offsets.BusinessMonthEnd.freqstr

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.freqstr.html

BusinessMonthEnd.freqstr

返回表示频率的字符串。

示例

>>> pd.DateOffset(5).freqstr
'<5 * DateOffsets>' 
>>> pd.offsets.BusinessHour(2).freqstr
'2bh' 
>>> pd.offsets.Nano().freqstr
'ns' 
>>> pd.offsets.Nano(-3).freqstr
'-3ns' 

pandas.tseries.offsets.BusinessMonthEnd.kwds

pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.kwds.html

BusinessMonthEnd.kwds

返回偏移量的额外参数字典。

示例

>>> pd.DateOffset(5).kwds
{} 
>>> pd.offsets.FY5253Quarter().kwds
{'weekday': 0,
 'startingMonth': 1,
 'qtr_with_extra_week': 1,
 'variation': 'nearest'} 

pandas.tseries.offsets.BusinessMonthEnd.name

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.name.html

BusinessMonthEnd.name

返回表示基本频率的字符串。

示例

>>> pd.offsets.Hour().name
'h' 
>>> pd.offsets.Hour(5).name
'h' 

pandas.tseries.offsets.BusinessMonthEnd.nanos

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.nanos.html

BusinessMonthEnd.nanos

pandas.tseries.offsets.BusinessMonthEnd.normalize

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.normalize.html

BusinessMonthEnd.normalize

pandas.tseries.offsets.BusinessMonthEnd.rule_code

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.rule_code.html

BusinessMonthEnd.rule_code

pandas.tseries.offsets.BusinessMonthEnd.n

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.n.html

BusinessMonthEnd.n

pandas.tseries.offsets.BusinessMonthEnd.copy

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.copy.html

BusinessMonthEnd.copy()

返回频率的副本。

示例

>>> freq = pd.DateOffset(1)
>>> freq_copy = freq.copy()
>>> freq is freq_copy
False 

pandas.tseries.offsets.BusinessMonthEnd.is_anchored

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.is_anchored.html

BusinessMonthEnd.is_anchored()

返回布尔值,指示频率是否为单位频率(n=1)。

自版本 2.2.0 起已弃用:is_anchored 已弃用,并将在将来的版本中移除。请改用obj.n == 1

示例

>>> pd.DateOffset().is_anchored()
True
>>> pd.DateOffset(2).is_anchored()
False 

pandas.tseries.offsets.BusinessMonthEnd.is_on_offset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.is_on_offset.html

BusinessMonthEnd.is_on_offset(dt)

返回布尔值,表示时间戳是否与此频率相交。

参数:

dtdatetime.datetime

要检查与频率相交的时间戳。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Day(1)
>>> freq.is_on_offset(ts)
True 
>>> ts = pd.Timestamp(2022, 8, 6)
>>> ts.day_name()
'Saturday'
>>> freq = pd.offsets.BusinessDay(1)
>>> freq.is_on_offset(ts)
False 

pandas.tseries.offsets.BusinessMonthEnd.is_month_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.is_month_start.html

BusinessMonthEnd.is_month_start(ts)

返回布尔值,指示时间戳是否出现在月初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.BusinessMonthEnd.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.is_month_end.html

BusinessMonthEnd.is_month_end(ts)

是否返回布尔值以指示时间戳是否发生在月末。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.BusinessMonthEnd.is_quarter_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.is_quarter_start.html

BusinessMonthEnd.is_quarter_start(ts)

返回一个布尔值,表示时间戳是否在季度开始时。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_start(ts)
True 

pandas.tseries.offsets.BusinessMonthEnd.is_quarter_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.is_quarter_end.html

BusinessMonthEnd.is_quarter_end(ts)

返回一个布尔值,指示时间戳是否在季度结束时发生。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_end(ts)
False 

pandas.tseries.offsets.BusinessMonthEnd.is_year_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.is_year_start.html

BusinessMonthEnd.is_year_start(ts)

返回一个布尔值,指示时间戳是否出现在年初。

例子

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_start(ts)
True 

pandas.tseries.offsets.BusinessMonthEnd.is_year_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthEnd.is_year_end.html

BusinessMonthEnd.is_year_end(ts)

返回一个布尔值,指示时间戳是否在年底。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_end(ts)
False 

pandas.tseries.offsets.BusinessMonthBegin

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.html

class pandas.tseries.offsets.BusinessMonthBegin

一个月的 DateOffset,在第一个工作日。

BusinessMonthBegin 转到下一个日期,即该月的第一个工作日。

参数:

nint,默认值为 1

表示的月数。

normalizebool,默认值为 False

将开始/结束日期标准化为生成日期范围之前的午夜。

另请参见

DateOffset

标准的日期增量类型。

示例

>>> ts = pd.Timestamp(2022, 11, 30)
>>> ts + pd.offsets.BMonthBegin()
Timestamp('2022-12-01 00:00:00') 
>>> ts = pd.Timestamp(2022, 12, 1)
>>> ts + pd.offsets.BMonthBegin()
Timestamp('2023-01-02 00:00:00') 

如果您想要获取当前工作月的开始:

>>> ts = pd.Timestamp(2022, 12, 1)
>>> pd.offsets.BMonthBegin().rollback(ts)
Timestamp('2022-12-01 00:00:00') 

属性

base 返回调用偏移对象的副本,其中 n=1,所有其他属性相等。
freqstr 返回表示频率的字符串。
kwds 返回偏移的额外参数的字典。
n
name 返回表示基本频率的字符串。
nanos
normalize
rule_code

方法

copy() 返回频率的副本。
is_anchored() (已弃用)返回频率是否为单位频率(n=1)的布尔值。
is_month_end(ts) 返回时间戳是否发生在月末的布尔值。
is_month_start(ts) 返回布尔值,指示时间戳是否出现在月初。
is_on_offset(dt) 返回布尔值,指示时间戳是否与此频率相交。
is_quarter_end(ts) 返回布尔值,指示时间戳是否出现在季度末。
is_quarter_start(ts) 返回布尔值,指示时间戳是否出现在季度初。
is_year_end(ts) 返回布尔值,指示时间戳是否出现在年底。
is_year_start(ts) 返回布尔值,指示时间戳是否出现在年初。
rollback(dt) 仅当不在偏移量上时,将提供的日期向后滚动到下一个偏移量。
rollforward(dt) 仅当不在偏移量上时,将提供的日期向前滚动到下一个偏移量。

pandas.tseries.offsets.BMonthBegin

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BMonthBegin.html

pandas.tseries.offsets.BMonthBegin

别名为BusinessMonthBegin

pandas.tseries.offsets.BusinessMonthBegin.freqstr

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.freqstr.html

BusinessMonthBegin.freqstr

返回一个表示频率的字符串。

示例

>>> pd.DateOffset(5).freqstr
'<5 * DateOffsets>' 
>>> pd.offsets.BusinessHour(2).freqstr
'2bh' 
>>> pd.offsets.Nano().freqstr
'ns' 
>>> pd.offsets.Nano(-3).freqstr
'-3ns' 

pandas.tseries.offsets.BusinessMonthBegin.kwds

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.kwds.html

BusinessMonthBegin.kwds

返回偏移量的额外参数字典。

示例

>>> pd.DateOffset(5).kwds
{} 
>>> pd.offsets.FY5253Quarter().kwds
{'weekday': 0,
 'startingMonth': 1,
 'qtr_with_extra_week': 1,
 'variation': 'nearest'} 

pandas.tseries.offsets.BusinessMonthBegin.name

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.name.html

BusinessMonthBegin.name

返回表示基本频率的字符串。

例子

>>> pd.offsets.Hour().name
'h' 
>>> pd.offsets.Hour(5).name
'h' 

pandas.tseries.offsets.BusinessMonthBegin.nanos

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.nanos.html

BusinessMonthBegin.nanos

pandas.tseries.offsets.BusinessMonthBegin.normalize

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.normalize.html

BusinessMonthBegin.normalize

pandas.tseries.offsets.BusinessMonthBegin.rule_code

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.rule_code.html

BusinessMonthBegin.rule_code

pandas.tseries.offsets.BusinessMonthBegin.n

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.n.html

BusinessMonthBegin.n

pandas.tseries.offsets.BusinessMonthBegin.copy

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.copy.html

BusinessMonthBegin.copy()

返回频率的副本。

示例

>>> freq = pd.DateOffset(1)
>>> freq_copy = freq.copy()
>>> freq is freq_copy
False 

pandas.tseries.offsets.BusinessMonthBegin.is_anchored

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.is_anchored.html

BusinessMonthBegin.is_anchored()

返回布尔值,表示频率是否为单位频率(n=1)。

自版本 2.2.0 起已弃用:is_anchored 已弃用,并将在将来的版本中移除。请使用 obj.n == 1 代替。

示例

>>> pd.DateOffset().is_anchored()
True
>>> pd.DateOffset(2).is_anchored()
False 

pandas.tseries.offsets.BusinessMonthBegin.is_on_offset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.is_on_offset.html

BusinessMonthBegin.is_on_offset(dt)

返回布尔值,指示时间戳是否与此频率相交。

参数:

dtdatetime.datetime

时间戳以检查与频率的交集。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Day(1)
>>> freq.is_on_offset(ts)
True 
>>> ts = pd.Timestamp(2022, 8, 6)
>>> ts.day_name()
'Saturday'
>>> freq = pd.offsets.BusinessDay(1)
>>> freq.is_on_offset(ts)
False 

pandas.tseries.offsets.BusinessMonthBegin.is_month_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.is_month_start.html

BusinessMonthBegin.is_month_start(ts)

返回布尔值,指示时间戳是否发生在月初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.BusinessMonthBegin.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.is_month_end.html

BusinessMonthBegin.is_month_end(ts)

返回一个布尔值,指示时间戳是否出现在月末。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.BusinessMonthBegin.is_quarter_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.is_quarter_start.html

BusinessMonthBegin.is_quarter_start(ts)

返回布尔值,表示时间戳是否出现在季度开始时。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_start(ts)
True 

pandas.tseries.offsets.BusinessMonthBegin.is_quarter_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.is_quarter_end.html

BusinessMonthBegin.is_quarter_end(ts)

返回一个布尔值,指示时间戳是否出现在季度结束。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_end(ts)
False 

pandas.tseries.offsets.BusinessMonthBegin.is_year_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.is_year_start.html

BusinessMonthBegin.is_year_start(ts)

返回时间戳是否发生在年初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_start(ts)
True 

pandas.tseries.offsets.BusinessMonthBegin.is_year_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.BusinessMonthBegin.is_year_end.html

BusinessMonthBegin.is_year_end(ts)

返回时间戳是否发生在年底的布尔值。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_end(ts)
False 

pandas.tseries.offsets.CustomBusinessMonthEnd

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.html

class pandas.tseries.offsets.CustomBusinessMonthEnd

代表自定义业务月份的 DateOffset 子类。

月末日期之间的增量。

参数:

nint,默认为 1

表示的月份数量。

normalizebool,默认为 False

将结束日期规范化为生成日期范围之前的午夜。

weekmaskstr,默认为‘周一 周二 周三 周四 周五’

有效工作日的 weekmask,传递给numpy.busdaycalendar

holidays列表

要排除的日期列表/数组,传递给numpy.busdaycalendar的有效工作日集合。

calendarnp.busdaycalendar

要集成的日历。

offsettimedelta,默认为 timedelta(0)

要应用的时间偏移量。

另请参见

DateOffset

标准日期增量类型。

示例

在下面的示例中,我们使用默认参数。

>>> ts = pd.Timestamp(2022, 8, 5)
>>> ts + pd.offsets.CustomBusinessMonthEnd()
Timestamp('2022-08-31 00:00:00') 

可以通过weekmask参数指定自定义的业务月末。要将返回的日期时间对象转换为其字符串表示形式,可以在下一个示例中使用函数 strftime()。

>>> import datetime as dt
>>> freq = pd.offsets.CustomBusinessMonthEnd(weekmask="Wed Thu")
>>> pd.date_range(dt.datetime(2022, 7, 10), dt.datetime(2022, 12, 18),
...               freq=freq).strftime('%a  %d %b %Y %H:%M')
Index(['Thu 28 Jul 2022 00:00', 'Wed 31 Aug 2022 00:00',
 'Thu 29 Sep 2022 00:00', 'Thu 27 Oct 2022 00:00',
 'Wed 30 Nov 2022 00:00'],
 dtype='object') 

使用 NumPy 工作日历,您可以定义自定义假期。

>>> import datetime as dt
>>> bdc = np.busdaycalendar(holidays=['2022-08-01', '2022-09-30',
...                                   '2022-10-31', '2022-11-01'])
>>> freq = pd.offsets.CustomBusinessMonthEnd(calendar=bdc)
>>> pd.date_range(dt.datetime(2022, 7, 10), dt.datetime(2022, 11, 10), freq=freq)
DatetimeIndex(['2022-07-29', '2022-08-31', '2022-09-29', '2022-10-28'],
 dtype='datetime64[ns]', freq='CBME') 

属性

base 返回调用偏移对象的副本,其中 n=1,所有其他属性相等。
calendar
cbday_roll 定义在 apply 方法中调用的默认滚动函数���
freqstr 返回表示频率的字符串。
holidays
kwds 返回偏移的额外参数字典。
m_offset
month_roll 定义在 apply 方法中调用的默认滚动函数。
n
name 返回表示基础频率的字符串。
nanos
normalize
offset 别名为 self._offset。
rule_code
weekmask

方法

copy() 返回频率的副本。
is_anchored() (已弃用)返回布尔值,指示频率是否为单位频率(n=1)。
is_month_end(ts) 返回布尔值,指示时间戳是否出现在月末。
is_month_start(ts) 返回布尔值,指示时间戳是否出现在月初。
is_on_offset(dt) 返回布尔值,指示时间戳是否与此频率相交。
is_quarter_end(ts) 返回布尔值,指示时间戳是否出现在季度末。
is_quarter_start(ts) 返回布尔值,指示时间戳是否出现在季度初。
is_year_end(ts) 返回一个布尔值,指示时间戳是否发生在年末。
is_year_start(ts) 返回一个布尔值,指示时间戳是否发生在年初。
rollback(dt) 仅当日期不在偏移量上时,将提供的日期向后滚动到下一个偏移量。
rollforward(dt) 仅当日期不在偏移量上时,将提供的日期向前滚动到下一个偏移量。

pandas.tseries.offsets.CBMonthEnd

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CBMonthEnd.html

pandas.tseries.offsets.CBMonthEnd

别名为CustomBusinessMonthEnd

pandas.tseries.offsets.CustomBusinessMonthEnd.freqstr

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.freqstr.html

CustomBusinessMonthEnd.freqstr

返回表示频率的字符串。

示例

>>> pd.DateOffset(5).freqstr
'<5 * DateOffsets>' 
>>> pd.offsets.BusinessHour(2).freqstr
'2bh' 
>>> pd.offsets.Nano().freqstr
'ns' 
>>> pd.offsets.Nano(-3).freqstr
'-3ns' 

pandas.tseries.offsets.CustomBusinessMonthEnd.kwds

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.kwds.html

CustomBusinessMonthEnd.kwds

返回偏移量的额外参数字典。

示例

>>> pd.DateOffset(5).kwds
{} 
>>> pd.offsets.FY5253Quarter().kwds
{'weekday': 0,
 'startingMonth': 1,
 'qtr_with_extra_week': 1,
 'variation': 'nearest'} 

pandas.tseries.offsets.CustomBusinessMonthEnd.m_offset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.m_offset.html

CustomBusinessMonthEnd.m_offset

pandas.tseries.offsets.CustomBusinessMonthEnd.name

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.name.html

CustomBusinessMonthEnd.name

返回表示基本频率的字符串。

示例

>>> pd.offsets.Hour().name
'h' 
>>> pd.offsets.Hour(5).name
'h' 

pandas.tseries.offsets.CustomBusinessMonthEnd.nanos

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.nanos.html

CustomBusinessMonthEnd.nanos

pandas.tseries.offsets.CustomBusinessMonthEnd.normalize

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.normalize.html

CustomBusinessMonthEnd.normalize

pandas.tseries.offsets.CustomBusinessMonthEnd.rule_code

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.rule_code.html

CustomBusinessMonthEnd.rule_code

pandas.tseries.offsets.CustomBusinessMonthEnd.n

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.n.html

CustomBusinessMonthEnd.n

pandas.tseries.offsets.CustomBusinessMonthEnd.weekmask

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.weekmask.html

CustomBusinessMonthEnd.weekmask

pandas.tseries.offsets.CustomBusinessMonthEnd.calendar

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.calendar.html

CustomBusinessMonthEnd.calendar

pandas.tseries.offsets.CustomBusinessMonthEnd.holidays

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.holidays.html

CustomBusinessMonthEnd.holidays

pandas.tseries.offsets.CustomBusinessMonthEnd.copy

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.copy.html

CustomBusinessMonthEnd.copy()

返回频率的副本。

示例

>>> freq = pd.DateOffset(1)
>>> freq_copy = freq.copy()
>>> freq is freq_copy
False 

pandas.tseries.offsets.CustomBusinessMonthEnd.is_anchored

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.is_anchored.html

CustomBusinessMonthEnd.is_anchored()

返回布尔值,指示频率是否为单位频率(n=1)。

自版本 2.2.0 起已弃用:is_anchored 已弃用,并将在未来版本中删除。请改用 obj.n == 1

示例

>>> pd.DateOffset().is_anchored()
True
>>> pd.DateOffset(2).is_anchored()
False 

pandas.tseries.offsets.CustomBusinessMonthEnd.is_on_offset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.is_on_offset.html

CustomBusinessMonthEnd.is_on_offset(dt)

返回布尔值,指示时间戳是否与此频率相交。

参数:

dtdatetime.datetime

用于检查与频率相交的时间戳。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Day(1)
>>> freq.is_on_offset(ts)
True 
>>> ts = pd.Timestamp(2022, 8, 6)
>>> ts.day_name()
'Saturday'
>>> freq = pd.offsets.BusinessDay(1)
>>> freq.is_on_offset(ts)
False 

pandas.tseries.offsets.CustomBusinessMonthEnd.is_month_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.is_month_start.html

CustomBusinessMonthEnd.is_month_start(ts)

返回布尔值,指示时间戳是否出现在月初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.CustomBusinessMonthEnd.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.is_month_end.html

CustomBusinessMonthEnd.is_month_end(ts)

返回一个布尔值,指示时间戳是否为月末。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.CustomBusinessMonthEnd.is_quarter_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.is_quarter_start.html

CustomBusinessMonthEnd.is_quarter_start(ts)

返回布尔值,指示时间戳是否发生在季度开始。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_start(ts)
True 

pandas.tseries.offsets.CustomBusinessMonthEnd.is_quarter_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.is_quarter_end.html

CustomBusinessMonthEnd.is_quarter_end(ts)

返回一个布尔值,指示时间戳是否发生在季度结束。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_end(ts)
False 

pandas.tseries.offsets.CustomBusinessMonthEnd.is_year_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.is_year_start.html

CustomBusinessMonthEnd.is_year_start(ts)

返回时间戳是否发生在年初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_start(ts)
True 

pandas.tseries.offsets.CustomBusinessMonthEnd.is_year_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthEnd.is_year_end.html

CustomBusinessMonthEnd.is_year_end(ts)

返回一个布尔值,指示时间戳是否发生在年底。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_end(ts)
False 

pandas.tseries.offsets.CustomBusinessMonthBegin

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.html

class pandas.tseries.offsets.CustomBusinessMonthBegin

表示自定义工作月份的 DateOffset 子类。

月初日期之间的增量。

参数:

n整数,默认为 1

表示的月份数。

normalize布尔值,默认为 False

在生成日期范围之前将开始日期归一化为午夜。

weekmaskstr,默认为‘Mon Tue Wed Thu Fri’

有效工作日的星期掩码,传递给numpy.busdaycalendar

holidays列表

要从有效工作日集中排除的日期列表/数组,传递给numpy.busdaycalendar

calendarnp.busdaycalendar

集成的日历。

offset时间增量,默认为 timedelta(0)

要应用的时间偏移。

参见

DateOffset

标准日期增量类型。

示例

在下面的示例中,我们使用默认参数。

>>> ts = pd.Timestamp(2022, 8, 5)
>>> ts + pd.offsets.CustomBusinessMonthBegin()
Timestamp('2022-09-01 00:00:00') 

可以通过weekmask参数指定自定义的工作月初。要将返回的日期时间对象转换为其字符串表示形式,下一个示例中使用了函数 strftime()。

>>> import datetime as dt
>>> freq = pd.offsets.CustomBusinessMonthBegin(weekmask="Wed Thu")
>>> pd.date_range(dt.datetime(2022, 7, 10), dt.datetime(2022, 12, 18),
...               freq=freq).strftime('%a  %d %b %Y %H:%M')
Index(['Wed 03 Aug 2022 00:00', 'Thu 01 Sep 2022 00:00',
 'Wed 05 Oct 2022 00:00', 'Wed 02 Nov 2022 00:00',
 'Thu 01 Dec 2022 00:00'],
 dtype='object') 

使用 NumPy 工作日历,您可以定义自定义假期。

>>> import datetime as dt
>>> bdc = np.busdaycalendar(holidays=['2022-08-01', '2022-09-30',
...                                   '2022-10-31', '2022-11-01'])
>>> freq = pd.offsets.CustomBusinessMonthBegin(calendar=bdc)
>>> pd.date_range(dt.datetime(2022, 7, 10), dt.datetime(2022, 11, 10), freq=freq)
DatetimeIndex(['2022-08-02', '2022-09-01', '2022-10-03', '2022-11-02'],
 dtype='datetime64[ns]', freq='CBMS') 

属性

base 返回调用偏移对象的副本,其中 n=1,所有其他属性相等。
calendar
cbday_roll 定义在应用方法中调用的默认滚动函数。
freqstr 返回表示频率的字符串。
holidays
kwds 返回偏移的额外参数字典。
m_offset
month_roll 定义在应用方法中调用的默认滚动函数。
n
name 返回表示基础频率的字符串。
nanos
normalize
offset self._offset 的别名。
rule_code
weekmask

方法

copy() 返回频率的副本。
is_anchored() (已弃用)返回一个布尔值,指示频率是否为单位频率(n=1)。
is_month_end(ts) 返回一个布尔值,指示时间戳是否在月底发生。
is_month_start(ts) 返回一个布尔值,指示时间戳是否在月初发生。
is_on_offset(dt) 返回一个布尔值,指示时间戳是否与此频率相交。
is_quarter_end(ts) 返回一个布尔值,指示时间戳是否在季度结束时发生。
is_quarter_start(ts) 返回时间戳是否在季度开始时发生的布尔值。
is_year_end(ts) 返回时间戳是否在年度结束时发生的布尔值。
is_year_start(ts) 返回时间戳是否在年度开始时发生的布尔值。
rollback(dt) 仅在不在偏移量上时,将提供的日期向后滚动到下一个偏移量。
rollforward(dt) 仅在不在偏移量上时,将提供的日期向前滚动到下一个偏移量。

pandas.tseries.offsets.CBMonthBegin

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CBMonthBegin.html

pandas.tseries.offsets.CBMonthBegin

CustomBusinessMonthBegin 的别名。

pandas.tseries.offsets.CustomBusinessMonthBegin.freqstr

原文链接

CustomBusinessMonthBegin.freqstr

返回表示频率的字符串。

示例

>>> pd.DateOffset(5).freqstr
'<5 * DateOffsets>' 
>>> pd.offsets.BusinessHour(2).freqstr
'2bh' 
>>> pd.offsets.Nano().freqstr
'ns' 
>>> pd.offsets.Nano(-3).freqstr
'-3ns' 

pandas.tseries.offsets.CustomBusinessMonthBegin.kwds

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.kwds.html

CustomBusinessMonthBegin.kwds

返回偏移量的额外参数字典。

示例

>>> pd.DateOffset(5).kwds
{} 
>>> pd.offsets.FY5253Quarter().kwds
{'weekday': 0,
 'startingMonth': 1,
 'qtr_with_extra_week': 1,
 'variation': 'nearest'} 

pandas.tseries.offsets.CustomBusinessMonthBegin.m_offset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.m_offset.html

CustomBusinessMonthBegin.m_offset

pandas.tseries.offsets.CustomBusinessMonthBegin.name

pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.name.html

CustomBusinessMonthBegin.name

返回表示基础频率的字符串。

示例

>>> pd.offsets.Hour().name
'h' 
>>> pd.offsets.Hour(5).name
'h' 

pandas.tseries.offsets.CustomBusinessMonthBegin.nanos

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.nanos.html

CustomBusinessMonthBegin.nanos

pandas.tseries.offsets.CustomBusinessMonthBegin.normalize

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.normalize.html

CustomBusinessMonthBegin.normalize

pandas.tseries.offsets.CustomBusinessMonthBegin.rule_code

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.rule_code.html

CustomBusinessMonthBegin.rule_code

pandas.tseries.offsets.CustomBusinessMonthBegin.n

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.n.html

CustomBusinessMonthBegin.n

pandas.tseries.offsets.CustomBusinessMonthBegin.weekmask

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.weekmask.html

CustomBusinessMonthBegin.weekmask

pandas.tseries.offsets.CustomBusinessMonthBegin.calendar

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.calendar.html

CustomBusinessMonthBegin.calendar

pandas.tseries.offsets.CustomBusinessMonthBegin.holidays

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.holidays.html

CustomBusinessMonthBegin.holidays

pandas.tseries.offsets.CustomBusinessMonthBegin.copy

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.copy.html

CustomBusinessMonthBegin.copy()

返回频率的副本。

示例

>>> freq = pd.DateOffset(1)
>>> freq_copy = freq.copy()
>>> freq is freq_copy
False 

pandas.tseries.offsets.CustomBusinessMonthBegin.is_anchored

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.is_anchored.html

CustomBusinessMonthBegin.is_anchored()

返回布尔值,指示频率是否为单位频率(n=1)。

Deprecated since version 2.2.0: is_anchored is deprecated and will be removed in a future version. Use obj.n == 1 instead.

示例

>>> pd.DateOffset().is_anchored()
True
>>> pd.DateOffset(2).is_anchored()
False 

pandas.tseries.offsets.CustomBusinessMonthBegin.is_on_offset

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.is_on_offset.html

CustomBusinessMonthBegin.is_on_offset(dt)

返回布尔值,指示时间戳是否与此频率相交。

参数:

dtdatetime.datetime

要检查与频率交集的时间戳。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Day(1)
>>> freq.is_on_offset(ts)
True 
>>> ts = pd.Timestamp(2022, 8, 6)
>>> ts.day_name()
'Saturday'
>>> freq = pd.offsets.BusinessDay(1)
>>> freq.is_on_offset(ts)
False 

pandas.tseries.offsets.CustomBusinessMonthBegin.is_month_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.is_month_start.html

CustomBusinessMonthBegin.is_month_start(ts)

返回一个布尔值,指示时间戳是否出现在月初。

例子

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_start(ts)
True 

pandas.tseries.offsets.CustomBusinessMonthBegin.is_month_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.is_month_end.html

CustomBusinessMonthBegin.is_month_end(ts)

返回一个布尔值,指示时间戳是否发生在月末。

例子

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_month_end(ts)
False 

pandas.tseries.offsets.CustomBusinessMonthBegin.is_quarter_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.is_quarter_start.html

CustomBusinessMonthBegin.is_quarter_start(ts)

返回一个布尔值,指示时间戳是否出现在季度开始。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_start(ts)
True 

pandas.tseries.offsets.CustomBusinessMonthBegin.is_quarter_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.is_quarter_end.html

CustomBusinessMonthBegin.is_quarter_end(ts)

返回布尔值,指示时间戳是否在季度结束时发生。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_quarter_end(ts)
False 

pandas.tseries.offsets.CustomBusinessMonthBegin.is_year_start

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.is_year_start.html

CustomBusinessMonthBegin.is_year_start(ts)

返回一个布尔值,表示时间戳是否发生在年初。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_start(ts)
True 

pandas.tseries.offsets.CustomBusinessMonthBegin.is_year_end

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.CustomBusinessMonthBegin.is_year_end.html

CustomBusinessMonthBegin.is_year_end(ts)

返回一个布尔值,指示时间戳是否发生在年底。

示例

>>> ts = pd.Timestamp(2022, 1, 1)
>>> freq = pd.offsets.Hour(5)
>>> freq.is_year_end(ts)
False 

pandas.tseries.offsets.SemiMonthEnd

原文:pandas.pydata.org/docs/reference/api/pandas.tseries.offsets.SemiMonthEnd.html

class pandas.tseries.offsets.SemiMonthEnd

每月两个 DateOffset,重复出现在月底和 day_of_month。

参数:

n整数,默认为 1

表示的月份数。

normalize布尔值,默认为 False

将开始/结束日期归一化为生成日期范围之前的午夜。

day_of_month整数,{1, 3,…,27},默认为 15

每月特定的整数日期。

示例

>>> 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') 

如果要获得当前月份的结果:

>>> ts = pd.Timestamp(2022, 1, 15)
>>> pd.offsets.SemiMonthEnd().rollforward(ts)
Timestamp('2022-01-15 00:00:00') 

属性

base 返回调用偏移对象的副本,其中 n=1,所有其他属性相等。
day_of_month
freqstr 返回表示频率的字符串。
kwds 返回偏移量的额外参数字典。
n
name 返回表示基础频率的字符串。
nanos
normalize
rule_code

方法

copy() 返回频率的副本。
is_anchored() (已弃用)返回布尔值,指示频率是否为单位频率(n=1)。
is_month_end 返回布尔值,指示时间戳是否在月末发生。
is_month_start(ts) 返回一个布尔值,指示时间戳是否出现在月初。
is_on_offset(dt) 返回一个布尔值,指示时间戳是否与此频率相交。
is_quarter_end(ts) 返回一个布尔值,指示时间戳是否出现在季末。
is_quarter_start(ts) 返回一个布尔值,指示时间戳是否出现在季初。
is_year_end(ts) 返回一个布尔值,指示时间戳是否出现在年末。
is_year_start(ts) 返回一个布尔值,指示时间戳是否出现在年初。
rollback(dt) 仅当不在偏移量上时,将提供的日期向后滚动到下一个偏移量。
rollforward(dt) 仅当不在偏移量上时,将提供的日期向前滚动到下一个偏移量。
posted @ 2024-06-24 16:32  绝不原创的飞龙  阅读(1)  评论(0编辑  收藏  举报