-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DOC: update the pandas.Series.dt.is_leap_year docstring #20150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
054ac69
f585cca
e32f613
605fd20
8615d93
132c335
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1753,7 +1753,32 @@ def freq(self, value): | |
is_leap_year = _field_accessor( | ||
'is_leap_year', | ||
'is_leap_year', | ||
"Logical indicating if the date belongs to a leap year") | ||
""" | ||
Return a boolean indicating if the date belongs to a leap year. | ||
|
||
A leap year is a year, occurring every four years, which has 366 days | ||
(instead of 365) including 29th of February as an intercalary day. | ||
|
||
Returns | ||
------- | ||
is_leap_year : Series of boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's no need to name the return value, only it's type. And it's missing the description.
|
||
|
||
Examples | ||
-------- | ||
>>> import pandas as pd | ||
>>> dates = pd.date_range("2012-01-01", "2015-01-01", freq="Y") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need to import pandas or numpy |
||
>>> dates_series = pd.Series(dates) | ||
>>> dates_series | ||
0 2012-12-31 | ||
1 2013-12-31 | ||
2 2014-12-31 | ||
dtype: datetime64[ns] | ||
>>> dates_series.dt.is_leap_year | ||
0 True | ||
1 False | ||
2 False | ||
dtype: bool | ||
""") | ||
|
||
@property | ||
def time(self): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are exceptions for this four year rule, years divisible by 100 are not leap years except if they are also divisible by 400.
From wiki:
"Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100, but these centurial years are leap years if they are exactly divisible by 400. For example, the years 1700, 1800, and 1900 were not leap years, but the years 1600 and 2000 were."