Skip to content

Commit 4446942

Browse files
committed
DOC: Fix docstrings with the sections in the wrong order pandas-dev#24280
1 parent 7b0fa8e commit 4446942

File tree

10 files changed

+104
-84
lines changed

10 files changed

+104
-84
lines changed

pandas/_libs/interval.pyx

+28-28
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,29 @@ cdef class Interval(IntervalMixin):
158158
Whether the interval is closed on the left-side, right-side, both or
159159
neither. See the Notes for more detailed explanation.
160160
161+
See Also
162+
--------
163+
IntervalIndex : An Index of Interval objects that are all closed on the
164+
same side.
165+
cut : Convert continuous data into discrete bins (Categorical
166+
of Interval objects).
167+
qcut : Convert continuous data into bins (Categorical of Interval objects)
168+
based on quantiles.
169+
Period : Represents a period of time.
170+
"""
171+
_typ = "interval"
172+
173+
cdef readonly object left
174+
"""Left bound for the interval"""
175+
176+
cdef readonly object right
177+
"""Right bound for the interval"""
178+
179+
cdef readonly str closed
180+
"""
181+
Whether the interval is closed on the left-side, right-side, both or
182+
neither
183+
161184
Notes
162185
-----
163186
The parameters `left` and `right` must be from the same type, you must be
@@ -226,29 +249,6 @@ cdef class Interval(IntervalMixin):
226249
>>> volume_1 = pd.Interval('Ant', 'Dog', closed='both')
227250
>>> 'Bee' in volume_1
228251
True
229-
230-
See Also
231-
--------
232-
IntervalIndex : An Index of Interval objects that are all closed on the
233-
same side.
234-
cut : Convert continuous data into discrete bins (Categorical
235-
of Interval objects).
236-
qcut : Convert continuous data into bins (Categorical of Interval objects)
237-
based on quantiles.
238-
Period : Represents a period of time.
239-
"""
240-
_typ = "interval"
241-
242-
cdef readonly object left
243-
"""Left bound for the interval"""
244-
245-
cdef readonly object right
246-
"""Right bound for the interval"""
247-
248-
cdef readonly str closed
249-
"""
250-
Whether the interval is closed on the left-side, right-side, both or
251-
neither
252252
"""
253253

254254
def __init__(self, left, right, str closed='right'):
@@ -387,6 +387,11 @@ cdef class Interval(IntervalMixin):
387387
bool
388388
``True`` if the two intervals overlap, else ``False``.
389389
390+
See Also
391+
--------
392+
IntervalArray.overlaps : The corresponding method for IntervalArray
393+
IntervalIndex.overlaps : The corresponding method for IntervalIndex
394+
390395
Examples
391396
--------
392397
>>> i1 = pd.Interval(0, 2)
@@ -409,11 +414,6 @@ cdef class Interval(IntervalMixin):
409414
>>> i6 = pd.Interval(1, 2, closed='neither')
410415
>>> i4.overlaps(i6)
411416
False
412-
413-
See Also
414-
--------
415-
IntervalArray.overlaps : The corresponding method for IntervalArray
416-
IntervalIndex.overlaps : The corresponding method for IntervalIndex
417417
"""
418418
if not isinstance(other, Interval):
419419
msg = '`other` must be an Interval, got {other}'

pandas/_libs/tslibs/timedeltas.pyx

+8-8
Original file line numberDiff line numberDiff line change
@@ -1059,6 +1059,10 @@ cdef class _Timedelta(timedelta):
10591059
-------
10601060
formatted : str
10611061
1062+
See Also
1063+
--------
1064+
Timestamp.isoformat
1065+
10621066
Notes
10631067
-----
10641068
The longest component is days, whose value may be larger than
@@ -1081,10 +1085,6 @@ cdef class _Timedelta(timedelta):
10811085
'P0DT0H0M10S'
10821086
>>> pd.Timedelta(days=500.5).isoformat()
10831087
'P500DT12H0MS'
1084-
1085-
See Also
1086-
--------
1087-
Timestamp.isoformat
10881088
"""
10891089
components = self.components
10901090
seconds = '{}.{:0>3}{:0>3}{:0>3}'.format(components.seconds,
@@ -1210,14 +1210,14 @@ class Timedelta(_Timedelta):
12101210
"""
12111211
Round the Timedelta to the specified resolution
12121212
1213-
Returns
1214-
-------
1215-
a new Timedelta rounded to the given resolution of `freq`
1216-
12171213
Parameters
12181214
----------
12191215
freq : a freq string indicating the rounding resolution
12201216
1217+
Returns
1218+
-------
1219+
a new Timedelta rounded to the given resolution of `freq`
1220+
12211221
Raises
12221222
------
12231223
ValueError if the freq cannot be converted

pandas/_libs/tslibs/timestamps.pyx

+4-4
Original file line numberDiff line numberDiff line change
@@ -776,10 +776,6 @@ class Timestamp(_Timestamp):
776776
"""
777777
Round the Timestamp to the specified resolution
778778
779-
Returns
780-
-------
781-
a new Timestamp rounded to the given resolution of `freq`
782-
783779
Parameters
784780
----------
785781
freq : a freq string indicating the rounding resolution
@@ -802,6 +798,10 @@ class Timestamp(_Timestamp):
802798
803799
.. versionadded:: 0.24.0
804800
801+
Returns
802+
-------
803+
a new Timestamp rounded to the given resolution of `freq`
804+
805805
Raises
806806
------
807807
ValueError if the freq cannot be converted

pandas/core/accessor.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ def decorator(accessor):
201201
Name under which the accessor should be registered. A warning is issued
202202
if this name conflicts with a preexisting attribute.
203203
204+
See Also
205+
--------
206+
%(others)s
207+
204208
Notes
205209
-----
206210
When accessed, your accessor will be initialized with the pandas object
@@ -250,10 +254,6 @@ def plot(self):
250254
(5.0, 10.0)
251255
>>> ds.geo.plot()
252256
# plots data on a map
253-
254-
See Also
255-
--------
256-
%(others)s
257257
"""
258258

259259

pandas/core/frame.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -6046,6 +6046,17 @@ def _gotitem(self,
60466046
axis=0)``.
60476047
60486048
`agg` is an alias for `aggregate`. Use the alias.
6049+
6050+
See Also
6051+
--------
6052+
DataFrame.apply : Perform any type of operations.
6053+
DataFrame.transform : Perform transformation type operations.
6054+
pandas.core.groupby.GroupBy : Perform operations over groups.
6055+
pandas.core.resample.Resampler : Perform operations over resampled bins.
6056+
pandas.core.window.Rolling : Perform operations over rolling window.
6057+
pandas.core.window.Expanding : Perform operations over expanding window.
6058+
pandas.core.window.EWM : Perform operation over exponential weighted
6059+
window.
60496060
60506061
Examples
60516062
--------
@@ -6078,23 +6089,12 @@ def _gotitem(self,
60786089
2 8.0
60796090
3 NaN
60806091
dtype: float64
6081-
6082-
See Also
6083-
--------
6084-
DataFrame.apply : Perform any type of operations.
6085-
DataFrame.transform : Perform transformation type operations.
6086-
pandas.core.groupby.GroupBy : Perform operations over groups.
6087-
pandas.core.resample.Resampler : Perform operations over resampled bins.
6088-
pandas.core.window.Rolling : Perform operations over rolling window.
6089-
pandas.core.window.Expanding : Perform operations over expanding window.
6090-
pandas.core.window.EWM : Perform operation over exponential weighted
6091-
window.
60926092
""")
60936093

6094-
@Appender(_agg_doc)
60956094
@Appender(_shared_docs['aggregate'] % dict(
60966095
versionadded='.. versionadded:: 0.20.0',
60976096
**_shared_doc_kwargs))
6097+
@Appender(_agg_doc)
60986098
def aggregate(self, func, axis=0, *args, **kwargs):
60996099
axis = self._get_axis_number(axis)
61006100

pandas/core/groupby/generic.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,12 @@ class DataFrameGroupBy(NDFrameGroupBy):
12471247
_block_agg_axis = 1
12481248

12491249
_agg_doc = dedent("""
1250+
See Also
1251+
--------
1252+
pandas.DataFrame.groupby.apply
1253+
pandas.DataFrame.groupby.transform
1254+
pandas.DataFrame.aggregate
1255+
12501256
Examples
12511257
--------
12521258
@@ -1294,19 +1300,13 @@ class DataFrameGroupBy(NDFrameGroupBy):
12941300
A
12951301
1 1 2 0.590716
12961302
2 3 4 0.704907
1297-
1298-
See Also
1299-
--------
1300-
pandas.DataFrame.groupby.apply
1301-
pandas.DataFrame.groupby.transform
1302-
pandas.DataFrame.aggregate
13031303
""")
13041304

1305-
@Appender(_agg_doc)
13061305
@Appender(_shared_docs['aggregate'] % dict(
13071306
klass='DataFrame',
13081307
versionadded='',
13091308
axis=''))
1309+
@Appender(_agg_doc)
13101310
def aggregate(self, arg, *args, **kwargs):
13111311
return super(DataFrameGroupBy, self).aggregate(arg, *args, **kwargs)
13121312

pandas/core/groupby/groupby.py

+24-4
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,6 @@ def count(self):
10801080
raise NotImplementedError
10811081

10821082
@Substitution(name='groupby')
1083-
@Appender(_doc_template)
10841083
def mean(self, *args, **kwargs):
10851084
"""
10861085
Compute mean of groups, excluding missing values.
@@ -1089,6 +1088,12 @@ def mean(self, *args, **kwargs):
10891088
-------
10901089
pandas.Series or pandas.DataFrame
10911090
1091+
See Also
1092+
--------
1093+
pandas.Series.%(name)s
1094+
pandas.DataFrame.%(name)s
1095+
pandas.Panel.%(name)s
1096+
10921097
Examples
10931098
--------
10941099
>>> df = pd.DataFrame({'A': [1, 1, 2, 1, 2],
@@ -1528,7 +1533,6 @@ def backfill(self, limit=None):
15281533
bfill = backfill
15291534

15301535
@Substitution(name='groupby')
1531-
@Appender(_doc_template)
15321536
def nth(self, n, dropna=None):
15331537
"""
15341538
Take the nth row from each group if n is an int, or a subset of rows
@@ -1547,6 +1551,12 @@ def nth(self, n, dropna=None):
15471551
apply the specified dropna operation before counting which row is
15481552
the nth row. Needs to be None, 'any' or 'all'
15491553
1554+
See Also
1555+
--------
1556+
pandas.Series.%(name)s
1557+
pandas.DataFrame.%(name)s
1558+
pandas.Panel.%(name)s
1559+
15501560
Examples
15511561
--------
15521562
@@ -2032,14 +2042,19 @@ def pct_change(self, periods=1, fill_method='pad', limit=None, freq=None,
20322042
return (filled / shifted) - 1
20332043

20342044
@Substitution(name='groupby')
2035-
@Appender(_doc_template)
20362045
def head(self, n=5):
20372046
"""
20382047
Returns first n rows of each group.
20392048
20402049
Essentially equivalent to ``.apply(lambda x: x.head(n))``,
20412050
except ignores as_index flag.
20422051
2052+
See Also
2053+
--------
2054+
pandas.Series.%(name)s
2055+
pandas.DataFrame.%(name)s
2056+
pandas.Panel.%(name)s
2057+
20432058
Examples
20442059
--------
20452060
@@ -2059,14 +2074,19 @@ def head(self, n=5):
20592074
return self._selected_obj[mask]
20602075

20612076
@Substitution(name='groupby')
2062-
@Appender(_doc_template)
20632077
def tail(self, n=5):
20642078
"""
20652079
Returns last n rows of each group.
20662080
20672081
Essentially equivalent to ``.apply(lambda x: x.tail(n))``,
20682082
except ignores as_index flag.
20692083
2084+
See Also
2085+
--------
2086+
pandas.Series.%(name)s
2087+
pandas.DataFrame.%(name)s
2088+
pandas.Panel.%(name)s
2089+
20702090
Examples
20712091
--------
20722092

pandas/core/resample.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,11 +253,11 @@ def pipe(self, func, *args, **kwargs):
253253
2013-01-01 00:00:04 5 NaN
254254
""")
255255

256-
@Appender(_agg_doc)
257256
@Appender(_shared_docs['aggregate'] % dict(
258257
klass='DataFrame',
259258
versionadded='',
260259
axis=''))
260+
@Appender(_agg_doc)
261261
def aggregate(self, func, *args, **kwargs):
262262

263263
self._set_binner()

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -3302,10 +3302,10 @@ def _gotitem(self, key, ndim, subset=None):
33023302
dtype: int64
33033303
""")
33043304

3305-
@Appender(_agg_doc)
33063305
@Appender(generic._shared_docs['aggregate'] % dict(
33073306
versionadded='.. versionadded:: 0.20.0',
33083307
**_shared_doc_kwargs))
3308+
@Appender(_agg_doc)
33093309
def aggregate(self, func, axis=0, *args, **kwargs):
33103310
# Validate the axis parameter
33113311
self._get_axis_number(axis)

0 commit comments

Comments
 (0)