pandas.tseries.offsets.YearEnd#

class pandas.tseries.offsets.YearEnd#

DateOffset increments between calendar year end dates.

YearEnd goes to the next date which is the end of the year.

Parameters:
nint, 默认值 1

表示的年数.

normalizebool,默认 False

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

monthint, default 12

一年的月份的具体整数.

参见

DateOffset

标准的日期增量类型。

Examples

>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts + pd.offsets.YearEnd()
Timestamp('2022-12-31 00:00:00')
>>> ts = pd.Timestamp(2022, 12, 31)
>>> ts + pd.offsets.YearEnd()
Timestamp('2023-12-31 00:00:00')
>>> ts = pd.Timestamp(2022, 1, 1)
>>> ts + pd.offsets.YearEnd(month=2)
Timestamp('2022-02-28 00:00:00')

If you want to get the end of the current year:

>>> ts = pd.Timestamp(2022, 12, 31)
>>> pd.offsets.YearEnd().rollforward(ts)
Timestamp('2022-12-31 00:00:00')

Attributes

base 

返回调用偏移量对象的副本,其中 n=1 且所有其他属性都相同。

freqstr 

返回表示频率的字符串。

kwds 

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

month 

n 

name 

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

nanos 

normalize 

rule_code 

Methods

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)

如果提供的日期不在偏移量上,则将其向前滚动到下一个偏移量。