From 6efd5f5d82640b879ae35a6e69de734e4bff45ac Mon Sep 17 00:00:00 2001 From: Alexander Ponomaroff Date: Thu, 6 Dec 2018 15:23:59 -0500 Subject: [PATCH 1/2] More GL07 error fixes --- pandas/_libs/interval.pyx | 30 +++++++++++++++--------------- pandas/_libs/tslibs/timedeltas.pyx | 16 ++++++++-------- pandas/_libs/tslibs/timestamps.pyx | 8 ++++---- pandas/core/accessor.py | 8 ++++---- pandas/core/groupby/groupby.py | 16 ++++++++-------- pandas/core/resample.py | 8 ++++---- pandas/core/window.py | 14 +++++++------- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/pandas/_libs/interval.pyx b/pandas/_libs/interval.pyx index dae88d3b707bf..1484a1299b246 100644 --- a/pandas/_libs/interval.pyx +++ b/pandas/_libs/interval.pyx @@ -158,6 +158,16 @@ cdef class Interval(IntervalMixin): Whether the interval is closed on the left-side, right-side, both or neither. See the Notes for more detailed explanation. + See Also + -------- + IntervalIndex : An Index of Interval objects that are all closed on the + same side. + cut : Convert continuous data into discrete bins (Categorical + of Interval objects). + qcut : Convert continuous data into bins (Categorical of Interval objects) + based on quantiles. + Period : Represents a period of time. + Notes ----- The parameters `left` and `right` must be from the same type, you must be @@ -226,16 +236,6 @@ cdef class Interval(IntervalMixin): >>> volume_1 = pd.Interval('Ant', 'Dog', closed='both') >>> 'Bee' in volume_1 True - - See Also - -------- - IntervalIndex : An Index of Interval objects that are all closed on the - same side. - cut : Convert continuous data into discrete bins (Categorical - of Interval objects). - qcut : Convert continuous data into bins (Categorical of Interval objects) - based on quantiles. - Period : Represents a period of time. """ _typ = "interval" @@ -387,6 +387,11 @@ cdef class Interval(IntervalMixin): bool ``True`` if the two intervals overlap, else ``False``. + See Also + -------- + IntervalArray.overlaps : The corresponding method for IntervalArray + IntervalIndex.overlaps : The corresponding method for IntervalIndex + Examples -------- >>> i1 = pd.Interval(0, 2) @@ -409,11 +414,6 @@ cdef class Interval(IntervalMixin): >>> i6 = pd.Interval(1, 2, closed='neither') >>> i4.overlaps(i6) False - - See Also - -------- - IntervalArray.overlaps : The corresponding method for IntervalArray - IntervalIndex.overlaps : The corresponding method for IntervalIndex """ if not isinstance(other, Interval): msg = '`other` must be an Interval, got {other}' diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index b0bead2f66ce4..904089cacf537 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -1059,6 +1059,10 @@ cdef class _Timedelta(timedelta): ------- formatted : str + See Also + -------- + Timestamp.isoformat + Notes ----- The longest component is days, whose value may be larger than @@ -1081,10 +1085,6 @@ cdef class _Timedelta(timedelta): 'P0DT0H0M10S' >>> pd.Timedelta(days=500.5).isoformat() 'P500DT12H0MS' - - See Also - -------- - Timestamp.isoformat """ components = self.components seconds = '{}.{:0>3}{:0>3}{:0>3}'.format(components.seconds, @@ -1210,14 +1210,14 @@ class Timedelta(_Timedelta): """ Round the Timedelta to the specified resolution - Returns - ------- - a new Timedelta rounded to the given resolution of `freq` - Parameters ---------- freq : a freq string indicating the rounding resolution + Returns + ------- + a new Timedelta rounded to the given resolution of `freq` + Raises ------ ValueError if the freq cannot be converted diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index b4862a5f3b02f..c581135c18baa 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -767,10 +767,6 @@ class Timestamp(_Timestamp): """ Round the Timestamp to the specified resolution - Returns - ------- - a new Timestamp rounded to the given resolution of `freq` - Parameters ---------- freq : a freq string indicating the rounding resolution @@ -793,6 +789,10 @@ class Timestamp(_Timestamp): .. versionadded:: 0.24.0 + Returns + ------- + a new Timestamp rounded to the given resolution of `freq` + Raises ------ ValueError if the freq cannot be converted diff --git a/pandas/core/accessor.py b/pandas/core/accessor.py index fa1dc751c17da..c5f9ebcbd5cb0 100644 --- a/pandas/core/accessor.py +++ b/pandas/core/accessor.py @@ -201,6 +201,10 @@ def decorator(accessor): Name under which the accessor should be registered. A warning is issued if this name conflicts with a preexisting attribute. +See Also +-------- +%(others)s + Notes ----- When accessed, your accessor will be initialized with the pandas object @@ -250,10 +254,6 @@ def plot(self): (5.0, 10.0) >>> ds.geo.plot() # plots data on a map - -See Also --------- -%(others)s """ diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 253860d83f49e..127cc9425cf06 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -977,6 +977,14 @@ class GroupBy(_GroupBy): name : string Most users should ignore this + Returns + ------- + **Attributes** + groups : dict + {group name -> group labels} + len(grouped) : int + Number of groups + Notes ----- After grouping, see aggregate, apply, and transform functions. Here are @@ -1010,14 +1018,6 @@ class GroupBy(_GroupBy): See the online documentation for full exposition on these topics and much more - - Returns - ------- - **Attributes** - groups : dict - {group name -> group labels} - len(grouped) : int - Number of groups """ def _bool_agg(self, val_test, skipna): """ diff --git a/pandas/core/resample.py b/pandas/core/resample.py index f2cf17f8f060d..785f6f376e0a3 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -51,13 +51,13 @@ class Resampler(_GroupBy): kind : str or None 'period', 'timestamp' to override default index treatement - Notes - ----- - After resampling, see aggregate, apply, and transform functions. - Returns ------- a Resampler of the appropriate type + + Notes + ----- + After resampling, see aggregate, apply, and transform functions. """ # to the groupby descriptor diff --git a/pandas/core/window.py b/pandas/core/window.py index 6c4dde54bd061..9310c4b556f41 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -1294,6 +1294,13 @@ def kurt(self, **kwargs): Returned object type is determined by the caller of the %(name)s calculation. + See Also + -------- + pandas.Series.quantile : Computes value at the given quantile over all data + in Series. + pandas.DataFrame.quantile : Computes values at the given quantile over + requested axis in DataFrame. + Examples -------- >>> s = pd.Series([1, 2, 3, 4]) @@ -1310,13 +1317,6 @@ def kurt(self, **kwargs): 2 2.5 3 3.5 dtype: float64 - - See Also - -------- - pandas.Series.quantile : Computes value at the given quantile over all data - in Series. - pandas.DataFrame.quantile : Computes values at the given quantile over - requested axis in DataFrame. """) def quantile(self, quantile, interpolation='linear', **kwargs): From 5c54db87e93723471a9e9f066d11a85610fb08d5 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 14 Dec 2018 17:53:33 +0000 Subject: [PATCH 2/2] Fixing docstring order (and test because NaT and Timestamp docstring did not match) --- pandas/_libs/tslibs/nattype.pyx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 42ec235992089..d61b3aa3135d1 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -471,10 +471,6 @@ class NaTType(_NaT): """ Round the Timestamp to the specified resolution - Returns - ------- - a new Timestamp rounded to the given resolution of `freq` - Parameters ---------- freq : a freq string indicating the rounding resolution @@ -497,6 +493,10 @@ class NaTType(_NaT): .. versionadded:: 0.24.0 + Returns + ------- + a new Timestamp rounded to the given resolution of `freq` + Raises ------ ValueError if the freq cannot be converted