Skip to content

Commit cce2f66

Browse files
authored
DOC: add examples to clarify the behavior of is_year_start for business offsets (#58975)
* add examples to is_year_start * add missing spaces * remove unnecessary spaces * add missing parentheses * update is_year_start example
1 parent bbe0e53 commit cce2f66

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

pandas/core/arrays/datetimes.py

+26
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,32 @@ def isocalendar(self) -> DataFrame:
21192119
21202120
>>> idx.is_year_start
21212121
array([False, False, True])
2122+
2123+
This method, when applied to Series with datetime values under
2124+
the ``.dt`` accessor, will lose information about Business offsets.
2125+
2126+
>>> dates = pd.Series(pd.date_range("2020-10-30", periods=4, freq="BYS"))
2127+
>>> dates
2128+
0 2021-01-01
2129+
1 2022-01-03
2130+
2 2023-01-02
2131+
3 2024-01-01
2132+
dtype: datetime64[ns]
2133+
2134+
>>> dates.dt.is_year_start
2135+
0 True
2136+
1 False
2137+
2 False
2138+
3 True
2139+
dtype: bool
2140+
2141+
>>> idx = pd.date_range("2020-10-30", periods=4, freq="BYS")
2142+
>>> idx
2143+
DatetimeIndex(['2021-01-01', '2022-01-03', '2023-01-02', '2024-01-01'],
2144+
dtype='datetime64[ns]', freq='BYS-JAN')
2145+
2146+
>>> idx.is_year_start
2147+
array([ True, True, True, True])
21222148
""",
21232149
)
21242150
is_year_end = _field_accessor(

0 commit comments

Comments
 (0)