Skip to content

DOC: update the pandas.Series.dt.is_leap_year docstring #20184

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

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Examples
--------
>>> import pandas as pd
>>> dates = pd.date_range("2012-01-01", "2015-01-01", freq="Y")
>>> 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):
Expand Down Expand Up @@ -1906,15 +1931,22 @@ def delete(self, loc):

def tz_convert(self, tz):
"""
Convert tz-aware DatetimeIndex from one time zone to another (using
pytz/dateutil)
Change time zone of Datetime series.

Convert tz-aware DatetimeIndex from one time zone to another or remove
time zone information. The time zone can be specified using a string,
pytz or dateutil.

Parameters
----------
tz : string, pytz.timezone, dateutil.tz.tzfile or None
tz : string, pytz.timezone, dateutil.tz.tzfile, None
Time zone for time. Corresponding timestamps would be converted to
time zone of the TimeSeries.
None will remove timezone holding UTC time.
None will remove timezone and return UTC timestamp.
args : iterable, optional
Additional arguments passed to the function.
kwargs : dict, optional
Additional keyword arguments passed to the function.

Returns
-------
Expand All @@ -1924,6 +1956,26 @@ def tz_convert(self, tz):
------
TypeError
If DatetimeIndex is tz-naive.

See Also
--------
tz_localize : Localize tz-naive DatetimeIndex to given time zone.

Examples
--------
>>> ts = pd.Series([pd.Timestamp("2018-01-01 00:00", tz="US/Eastern"),
... pd.Timestamp("2018-02-01 23:00", tz="US/Eastern")])
>>> ts.dt.tz_convert("Europe/Amsterdam")
0 2018-01-01 06:00:00+01:00
1 2018-02-02 05:00:00+01:00
dtype: datetime64[ns, Europe/Amsterdam]

>>> import pytz
>>> pacific = pytz.timezone('US/Pacific')
>>> ts = pd.Series([pd.Timestamp("2018-01-01 01:00", tz=pacific)])
>>> ts.dt.tz_convert(tz=None)
0 2018-01-01 09:00:00
dtype: datetime64[ns]
"""
tz = timezones.maybe_get_tz(tz)

Expand Down