diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index 78cc54db4b1b8..8677bf53330eb 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -446,12 +446,18 @@ def to_timestamp(self, freq=None, how="start"): ---------- freq : str or DateOffset, optional Target frequency. The default is 'D' for week or longer, - 'S' otherwise + 'S' otherwise. how : {'s', 'e', 'start', 'end'} + Convert to timestamp using start or end of period. + *args + Positional arguments passed. + **kwargs + Keyword arguments passed. Returns ------- DatetimeArray/Index + As a timestamp. """ from pandas.core.arrays import DatetimeArray @@ -539,17 +545,22 @@ def asfreq(self, freq=None, how="E"): Parameters ---------- freq : str - a frequency + A frequency. how : str {'E', 'S'} - 'E', 'END', or 'FINISH' for end, - 'S', 'START', or 'BEGIN' for start. + Use 'E', 'END', or 'FINISH' for end, + Use 'S', 'START', or 'BEGIN' for start. Whether the elements should be aligned to the end or start within pa period. January 31st ('END') vs. January 1st ('START') for example. + *args + Positional arguments passed. + **kwargs + Keyword arguments passed. Returns ------- - new : Period Array/Index with the new frequency + PeriodArray or PeriodIndex + Wwith the new frequency. Examples -------- diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index a20290e77023a..209fc1acdcf84 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -77,20 +77,24 @@ class PeriodDelegateMixin(DatetimelikeDelegateMixin): ) class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): """ - Immutable ndarray holding ordinal values indicating regular periods in - time such as particular years, quarters, months, etc. + Holds ordinal time values. - Index keys are boxed to Period objects which carries the metadata (eg, - frequency information). + An immutable ndarray. Indicates regular periods in time such as particular years, + quarters, months, etc. Index keys are boxed to Period objects which carries the + metadata (eg, frequency information). If `ordinal` and `data` are not used, the + time values are passed to :meth: `_generate_range()`. Parameters ---------- + name : default None + A name for the data. + ordinal : default None data : array-like (1d int np.ndarray or PeriodArray), optional - Optional period-like data to construct index with + Optional period-like data to construct index with. copy : bool - Make a copy of input ndarray + Make a copy of input ndarray. freq : str or period object, optional - One of pandas period strings or corresponding objects + One of pandas period strings or corresponding objects. start : starting value, period-like, optional If data is None, used as the start point in generating regular period data. @@ -99,25 +103,32 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): periods : int, optional, > 0 Number of periods to generate, if generating index. Takes precedence - over end argument + over end argument. .. deprecated:: 0.24.0 end : end value, period-like, optional If periods is none, generated index will extend to first conforming - period on or just past end argument + period on or just past end argument. .. deprecated:: 0.24.0 year : int, array, or Series, default None + Year value of period. month : int, array, or Series, default None + Month value of period. quarter : int, array, or Series, default None + Quarter value of period. day : int, array, or Series, default None + Day value of period. hour : int, array, or Series, default None + Hour value of period. minute : int, array, or Series, default None + Minute value of period. second : int, array, or Series, default None + Second value of period. tz : object, default None - Timezone for converting datetime64 data to Periods + Timezone for converting datetime64 data to Periods. dtype : str or PeriodDtype, default None Attributes @@ -161,11 +172,12 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): ----- Creating a PeriodIndex based on `start`, `periods`, and `end` has been deprecated in favor of :func:`period_range`. - - Examples - -------- - >>> idx = pd.PeriodIndex(year=year_arr, quarter=q_arr) """ + # Example not currently passing tests + # Examples + # -------- + # >>> idx = pd.PeriodIndex(year=year_arr, quarter=q_arr) + # """ _typ = "periodindex" _attributes = ["name", "freq"]