Skip to content

Commit f7a5682

Browse files
rokjorisvandenbossche
authored andcommitted
DOC: update the pandas.Series.dt.is_leap_year docstring (#20150)
1 parent 6d20a36 commit f7a5682

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

pandas/core/indexes/datetimes.py

+37-1
Original file line numberDiff line numberDiff line change
@@ -1945,7 +1945,43 @@ def freq(self, value):
19451945
is_leap_year = _field_accessor(
19461946
'is_leap_year',
19471947
'is_leap_year',
1948-
"Logical indicating if the date belongs to a leap year")
1948+
"""
1949+
Boolean indicator if the date belongs to a leap year.
1950+
1951+
A leap year is a year, which has 366 days (instead of 365) including
1952+
29th of February as an intercalary day.
1953+
Leap years are years which are multiples of four with the exception
1954+
of years divisible by 100 but not by 400.
1955+
1956+
Returns
1957+
-------
1958+
Series or ndarray
1959+
Booleans indicating if dates belong to a leap year.
1960+
1961+
Examples
1962+
--------
1963+
This method is available on Series with datetime values under
1964+
the ``.dt`` accessor, and directly on DatetimeIndex.
1965+
1966+
>>> idx = pd.date_range("2012-01-01", "2015-01-01", freq="Y")
1967+
>>> idx
1968+
DatetimeIndex(['2012-12-31', '2013-12-31', '2014-12-31'],
1969+
dtype='datetime64[ns]', freq='A-DEC')
1970+
>>> idx.is_leap_year
1971+
array([ True, False, False], dtype=bool)
1972+
1973+
>>> dates = pd.Series(idx)
1974+
>>> dates_series
1975+
0 2012-12-31
1976+
1 2013-12-31
1977+
2 2014-12-31
1978+
dtype: datetime64[ns]
1979+
>>> dates_series.dt.is_leap_year
1980+
0 True
1981+
1 False
1982+
2 False
1983+
dtype: bool
1984+
""")
19491985

19501986
@property
19511987
def time(self):

0 commit comments

Comments
 (0)