pandas.DatetimeIndex.year#

property DatetimeIndex.year[source]#

The year of the datetime.

See also

DatetimeIndex.month

The month as January=1, December=12.

DatetimeIndex.day

The day of the datetime.

Examples

>>> datetime_series = pd.Series(
...     pd.date_range("2000-01-01", periods=3, freq="YE")
... )
>>> datetime_series
0   2000-12-31
1   2001-12-31
2   2002-12-31
dtype: datetime64[ns]
>>> datetime_series.dt.year
0    2000
1    2001
2    2002
dtype: int32