pandas.DatetimeIndex.year#

property DatetimeIndex.year[source]#

The year of the datetime.

This attribute returns the year component of each datetime value in the DatetimeIndex.

See also

DatetimeIndex.month

The month as January=1, December=12.

DatetimeIndex.day

The day of the datetime.

Examples

>>> idx = pd.DatetimeIndex(["2000-12-31", "2001-12-31", "2002-12-31"])
>>> idx.year
Index([2000, 2001, 2002], dtype='int32')