Skip to content

DOC: Fixing EX01 - Added examples #53465

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

Merged
merged 3 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
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
10 changes: 0 additions & 10 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
pandas.TimedeltaIndex.as_unit \
pandas.TimedeltaIndex.to_pytimedelta \
pandas.TimedeltaIndex.mean \
pandas.PeriodIndex.day \
pandas.PeriodIndex.dayofweek \
pandas.PeriodIndex.day_of_week \
pandas.PeriodIndex.dayofyear \
pandas.PeriodIndex.day_of_year \
pandas.PeriodIndex.days_in_month \
pandas.PeriodIndex.daysinmonth \
pandas.PeriodIndex.end_time \
pandas.PeriodIndex.freqstr \
pandas.PeriodIndex.hour \
pandas.core.window.rolling.Rolling.max \
pandas.core.window.rolling.Rolling.cov \
pandas.core.window.rolling.Rolling.skew \
Expand Down
9 changes: 9 additions & 0 deletions pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1684,6 +1684,15 @@ cdef class PeriodMixin:
1 2020-02-29 23:59:59.999999999
2 2020-03-31 23:59:59.999999999
dtype: datetime64[ns]

For PeriodIndex:

>>> idx = pd.PeriodIndex(["2023-01", "2023-02", "2023-03"], freq="M")
>>> idx.end_time
DatetimeIndex(['2023-01-31 23:59:59.999999999',
'2023-02-28 23:59:59.999999999',
'2023-03-31 23:59:59.999999999'],
dtype='datetime64[ns]', freq=None)
"""
return self.to_timestamp(how="end")

Expand Down
8 changes: 8 additions & 0 deletions pandas/core/arrays/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,8 @@ def freqstr(self) -> str | None:

Examples
--------
For DatetimeIndex:

>>> idx = pd.DatetimeIndex(["1/1/2020 10:00:00+00:00"], freq="D")
>>> idx.freqstr
'D'
Expand All @@ -839,6 +841,12 @@ def freqstr(self) -> str | None:
... freq="infer")
>>> idx.freqstr
'2D'

For PeriodIndex:

>>> idx = pd.PeriodIndex(["2023-1", "2023-2", "2023-3"], freq="M")
>>> idx.freqstr
'M'
"""
if self.freq is None:
return None
Expand Down
26 changes: 26 additions & 0 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,12 @@ def __arrow_array__(self, type=None):
"hour",
"""
The hour of the period.

Examples
--------
>>> idx = pd.PeriodIndex(["2023-01-01 10:00", "2023-01-01 11:00"], freq='H')
>>> idx.hour
Index([10, 11], dtype='int64')
""",
)
minute = _field_accessor(
Expand Down Expand Up @@ -514,6 +520,18 @@ def __arrow_array__(self, type=None):
"day_of_year",
"""
The ordinal day of the year.

Examples
--------
>>> idx = pd.PeriodIndex(["2023-01-10", "2023-02-01", "2023-03-01"], freq="D")
>>> idx.dayofyear
Index([10, 32, 60], dtype='int64')

>>> idx = pd.PeriodIndex(["2023", "2024", "2025"], freq="Y")
>>> idx
PeriodIndex(['2023', '2024', '2025'], dtype='period[A-DEC]')
>>> idx.dayofyear
Index([365, 366, 365], dtype='int64')
""",
)
quarter = _field_accessor(
Expand All @@ -536,6 +554,8 @@ def __arrow_array__(self, type=None):

Examples
--------
For Series:

>>> period = pd.period_range('2020-1-1 00:00', '2020-3-1 00:00', freq='M')
>>> s = pd.Series(period)
>>> s
Expand All @@ -548,6 +568,12 @@ def __arrow_array__(self, type=None):
1 29
2 31
dtype: int64

For PeriodIndex:

>>> idx = pd.PeriodIndex(["2023-01", "2023-02", "2023-03"], freq="M")
>>> idx.days_in_month # It can be also entered as `daysinmonth`
Index([31, 28, 31], dtype='int64')
""",
)
daysinmonth = days_in_month
Expand Down