Skip to content

Commit

Permalink
DOC: add examples to clarify the behavior of is_year_start for busi…
Browse files Browse the repository at this point in the history
…ness offsets (#58975)

* add examples to is_year_start

* add missing spaces

* remove unnecessary spaces

* add missing parentheses

* update is_year_start example
  • Loading branch information
natmokval committed Jun 12, 2024
1 parent bbe0e53 commit cce2f66
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2119,6 +2119,32 @@ def isocalendar(self) -> DataFrame:
>>> idx.is_year_start
array([False, False, True])
This method, when applied to Series with datetime values under
the ``.dt`` accessor, will lose information about Business offsets.
>>> dates = pd.Series(pd.date_range("2020-10-30", periods=4, freq="BYS"))
>>> dates
0 2021-01-01
1 2022-01-03
2 2023-01-02
3 2024-01-01
dtype: datetime64[ns]
>>> dates.dt.is_year_start
0 True
1 False
2 False
3 True
dtype: bool
>>> idx = pd.date_range("2020-10-30", periods=4, freq="BYS")
>>> idx
DatetimeIndex(['2021-01-01', '2022-01-03', '2023-01-02', '2024-01-01'],
dtype='datetime64[ns]', freq='BYS-JAN')
>>> idx.is_year_start
array([ True, True, True, True])
""",
)
is_year_end = _field_accessor(
Expand Down

0 comments on commit cce2f66

Please sign in to comment.