- API reference
- Series
- pandas.Serie...
pandas.Series.dt.is_leap_year#
- Series.dt.is_leap_year[source]#
Boolean indicator if the date belongs to a leap year.
A leap year is a year, which has 366 days (instead of 365) including29th of February as an intercalary day.Leap years are years which are multiples of four with the exceptionof years divisible by 100 but not by 400.
- Returns:
- Series or ndarray
Booleans indicating if dates belong to a leap year.
Examples
This method is available on Series with datetime values underthe
.dtaccessor, and directly on DatetimeIndex.>>>idx=pd.date_range("2012-01-01","2015-01-01",freq="YE")>>>idxDatetimeIndex(['2012-12-31', '2013-12-31', '2014-12-31'], dtype='datetime64[ns]', freq='YE-DEC')>>>idx.is_leap_yeararray([ True, False, False])
>>>dates_series=pd.Series(idx)>>>dates_series0 2012-12-311 2013-12-312 2014-12-31dtype: datetime64[ns]>>>dates_series.dt.is_leap_year0 True1 False2 Falsedtype: bool
On this page