From 521cecbe3bdba0eea5b1d8d0027716bc44f22f20 Mon Sep 17 00:00:00 2001 From: hughkelley Date: Fri, 25 Oct 2019 14:45:45 +0100 Subject: [PATCH 1/9] Add formatting and desc. to PeriodIndex. Comment out failing example. --- pandas/core/indexes/period.py | 37 +++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index a20290e77023a..3e508884e1bc2 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -77,20 +77,23 @@ 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, + 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). Parameters ---------- + **fields + name + ordinal 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 +102,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 +171,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"] From 03995176c96cb07740ff01af3f7a95df766e1933 Mon Sep 17 00:00:00 2001 From: hughkelley Date: Fri, 25 Oct 2019 15:00:32 +0100 Subject: [PATCH 2/9] add descriptions and defaults --- pandas/core/indexes/period.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 3e508884e1bc2..094b79f98352c 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -86,8 +86,10 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): Parameters ---------- **fields - name - ordinal + Dictionary of the keyword arguments. + 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. copy : bool From 287653c60f66a5d400329de6f325a430490d5d8b Mon Sep 17 00:00:00 2001 From: hughkelley Date: Fri, 25 Oct 2019 15:16:22 +0100 Subject: [PATCH 3/9] formatting and descriptions for PeriodIndex.asfreq --- pandas/core/arrays/period.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index 78cc54db4b1b8..fea1e4529970b 100644 --- a/pandas/core/arrays/period.py +++ b/pandas/core/arrays/period.py @@ -539,17 +539,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 -------- From 5823f2a38a1ae5bb546aea3165d8b586a537f275 Mon Sep 17 00:00:00 2001 From: hughkelley Date: Fri, 25 Oct 2019 15:24:38 +0100 Subject: [PATCH 4/9] formatting and descriptions --- pandas/core/arrays/period.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pandas/core/arrays/period.py b/pandas/core/arrays/period.py index fea1e4529970b..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 From 9c93cb20decadf4c951bc4ae0b4db09134181ea6 Mon Sep 17 00:00:00 2001 From: hughkelley Date: Fri, 25 Oct 2019 15:29:10 +0100 Subject: [PATCH 5/9] fix whitespace --- pandas/core/indexes/period.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 094b79f98352c..31e5053415fcf 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -79,7 +79,7 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): """ Holds ordinal time values. - An immutable ndarray. Indicates regular periods in time such as particular years, + 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). @@ -174,11 +174,11 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): Creating a PeriodIndex based on `start`, `periods`, and `end` has been deprecated in favor of :func:`period_range`. """ - # Example not currently passing tests - # 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"] From 98cdb672536d3078286a356e75a4fbf5656620ce Mon Sep 17 00:00:00 2001 From: hughkelley Date: Fri, 25 Oct 2019 15:31:00 +0100 Subject: [PATCH 6/9] fix line length --- pandas/core/indexes/period.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 31e5053415fcf..449e59b885649 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -80,8 +80,8 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): Holds ordinal time values. 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). + quarters, months, etc. Index keys are boxed to Period objects which carries the + metadata (eg, frequency information). Parameters ---------- From 15bdde31d7b1cfb689daeb38bf0bcbb1581cc212 Mon Sep 17 00:00:00 2001 From: hughkelley Date: Fri, 25 Oct 2019 15:31:59 +0100 Subject: [PATCH 7/9] whitespace after changing linebreak --- pandas/core/indexes/period.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 449e59b885649..013dca1df24df 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -80,7 +80,7 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): Holds ordinal time values. 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 + quarters, months, etc. Index keys are boxed to Period objects which carries the metadata (eg, frequency information). Parameters From e4120e5dd32677e63eaffe8612a18c130e6db42e Mon Sep 17 00:00:00 2001 From: hughkelley Date: Tue, 29 Oct 2019 14:17:18 +0000 Subject: [PATCH 8/9] fix fields description --- pandas/core/indexes/period.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 013dca1df24df..7254868a4dfe0 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -81,12 +81,11 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): 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). + metadata (eg, frequency information). If `ordinal` and `data` are not used, the + time values are passed to :meth: `_generate_range()`. Parameters ---------- - **fields - Dictionary of the keyword arguments. name : default None A name for the data. ordinal : default None From cc87ee1af1296a1c273aa66739fc1070c5bf7859 Mon Sep 17 00:00:00 2001 From: hughkelley Date: Tue, 29 Oct 2019 14:19:50 +0000 Subject: [PATCH 9/9] whitespace --- pandas/core/indexes/period.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/period.py b/pandas/core/indexes/period.py index 7254868a4dfe0..209fc1acdcf84 100644 --- a/pandas/core/indexes/period.py +++ b/pandas/core/indexes/period.py @@ -81,7 +81,7 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin): 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 + metadata (eg, frequency information). If `ordinal` and `data` are not used, the time values are passed to :meth: `_generate_range()`. Parameters