Skip to content
Merged
Changes from 2 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
28 changes: 27 additions & 1 deletion pandas/core/indexes/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,33 @@ def freq(self, value):
is_year_end = _field_accessor(
'is_year_end',
'is_year_end',
"Logical indicating if last day of year (defined by frequency)")
"""
Return a boolean indicating whether the date is the last day of the
year.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a single line. Does

Return a boolean array of whether the date is the year's last day.

fit on a single line?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boolean array is not correct in case of Series ...

(but I agree that just "boolean" does not reflect is returns a boolean for each element)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps just

Return an indicator for whether each date is the last day of the year.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's better. Or maybe even shorter "Indicate whether ..." instead of "Return an indicator whether .." ?


Returns
-------
is_year_end : Series of boolean.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this return type depends on the type of self. So I think

is_year_end : Series or DatetimeIndex
The same type as the original data. Series will have the same
name and index. DatetimeIndex will have the same name.


See Also
--------
is_year_start : Return a boolean indicating whether the date is the
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment #20275 (comment) (once we figure out how to handle these)

first day of the year.

Examples
--------
>>> dates = pd.Series(pd.date_range("2017-12-30", periods=3))
>>> dates
0 2017-12-30
1 2017-12-31
2 2018-01-01
dtype: datetime64[ns]
>>> dates.dt.is_year_end
0 False
1 True
2 False
dtype: bool
""")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add an example with just a DatetimeIndex? Can be the same values, and don't have to show the values again,

>>> pd.date_range('2017-12-30", periods=3).is_year_end

and show the output

is_leap_year = _field_accessor(
'is_leap_year',
'is_leap_year',
Expand Down