Skip to content

Commit 23b6115

Browse files
Scowley4datapythonista
authored andcommitted
DOC: Fix section headers in docstrings (#26301)
1 parent 7bfbd81 commit 23b6115

28 files changed

+114
-119
lines changed

pandas/core/arrays/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1059,8 +1059,8 @@ def _create_method(cls, op, coerce_to_dtype=True):
10591059
`op` cannot be stored in the ExtensionArray. The dtype of the
10601060
ndarray uses NumPy's normal inference rules.
10611061
1062-
Example
1063-
-------
1062+
Examples
1063+
--------
10641064
Given an ExtensionArray subclass called MyExtensionArray, use
10651065
10661066
>>> __add__ = cls._create_method(operator.add)

pandas/core/arrays/categorical.py

+10-15
Original file line numberDiff line numberDiff line change
@@ -2140,23 +2140,18 @@ def _reverse_indexer(self):
21402140
-------
21412141
dict of categories -> indexers
21422142
2143-
Example
2144-
-------
2145-
In [1]: c = pd.Categorical(list('aabca'))
2146-
2147-
In [2]: c
2148-
Out[2]:
2143+
Examples
2144+
--------
2145+
>>> c = pd.Categorical(list('aabca'))
2146+
>>> c
21492147
[a, a, b, c, a]
21502148
Categories (3, object): [a, b, c]
2151-
2152-
In [3]: c.categories
2153-
Out[3]: Index(['a', 'b', 'c'], dtype='object')
2154-
2155-
In [4]: c.codes
2156-
Out[4]: array([0, 0, 1, 2, 0], dtype=int8)
2157-
2158-
In [5]: c._reverse_indexer()
2159-
Out[5]: {'a': array([0, 1, 4]), 'b': array([2]), 'c': array([3])}
2149+
>>> c.categories
2150+
Index(['a', 'b', 'c'], dtype='object')
2151+
>>> c.codes
2152+
array([0, 0, 1, 2, 0], dtype=int8)
2153+
>>> c._reverse_indexer()
2154+
{'a': array([0, 1, 4]), 'b': array([2]), 'c': array([3])}
21602155
21612156
"""
21622157
categories = self.categories

pandas/core/arrays/datetimes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ def __iter__(self):
586586
Return an iterator over the boxed values
587587
588588
Yields
589-
-------
589+
------
590590
tstamp : Timestamp
591591
"""
592592

pandas/core/arrays/interval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
qcut : Bin values into equal-sized Intervals based on rank or sample quantiles.
9494
9595
Notes
96-
------
96+
-----
9797
See the `user guide
9898
<http://pandas.pydata.org/pandas-docs/stable/advanced.html#intervalindex>`_
9999
for more.

pandas/core/arrays/sparse.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,7 @@ def from_coo(cls, A, dense_index=False):
19551955
s : SparseSeries
19561956
19571957
Examples
1958-
---------
1958+
--------
19591959
>>> from scipy import sparse
19601960
>>> A = sparse.coo_matrix(([3.0, 1.0, 2.0], ([1, 0, 0], [0, 2, 3])),
19611961
shape=(3, 4))

pandas/core/dtypes/common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ def is_dtype_equal(source, target):
763763
target : The second dtype to compare
764764
765765
Returns
766-
----------
766+
-------
767767
boolean
768768
Whether or not the two dtypes are equal.
769769
@@ -804,7 +804,7 @@ def is_dtype_union_equal(source, target):
804804
target : The second dtype to compare
805805
806806
Returns
807-
----------
807+
-------
808808
boolean
809809
Whether or not the two dtypes are equal.
810810

pandas/core/frame.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7250,7 +7250,7 @@ def corrwith(self, other, axis=0, drop=False, method='pearson'):
72507250
Pairwise correlations.
72517251
72527252
See Also
7253-
-------
7253+
--------
72547254
DataFrame.corr
72557255
"""
72567256
axis = self._get_axis_number(axis)

pandas/core/generic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10327,11 +10327,11 @@ def transform(self, func, *args, **kwargs):
1032710327
Return index for %(position)s non-NA/null value.
1032810328
1032910329
Returns
10330-
--------
10330+
-------
1033110331
scalar : type of index
1033210332
1033310333
Notes
10334-
--------
10334+
-----
1033510335
If all elements are non-NA/null, returns None.
1033610336
Also returns None for empty %(klass)s.
1033710337
"""

pandas/core/groupby/groupby.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -799,13 +799,13 @@ def _try_cast(self, result, obj, numeric_only=False):
799799

800800
def _transform_should_cast(self, func_nm):
801801
"""
802-
Parameters:
803-
-----------
802+
Parameters
803+
----------
804804
func_nm: str
805805
The name of the aggregation function being performed
806806
807-
Returns:
808-
--------
807+
Returns
808+
-------
809809
bool
810810
Whether transform should attempt to cast the result of aggregation
811811
"""

pandas/core/indexes/base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class Index(IndexOpsMixin, PandasObject):
183183
When True, attempt to create a MultiIndex if possible
184184
185185
See Also
186-
---------
186+
--------
187187
RangeIndex : Index implementing a monotonic integer range.
188188
CategoricalIndex : Index of :class:`Categorical` s.
189189
MultiIndex : A multi-level, or hierarchical, Index.
@@ -2649,7 +2649,7 @@ def _convert_can_do_setop(self, other):
26492649
loc : int if unique index, slice if monotonic index, else mask
26502650
26512651
Examples
2652-
---------
2652+
--------
26532653
>>> unique_index = pd.Index(list('abc'))
26542654
>>> unique_index.get_loc('b')
26552655
1
@@ -4699,7 +4699,7 @@ def slice_indexer(self, start=None, end=None, step=None, kind=None):
46994699
This function assumes that the data is sorted, so use at your own peril
47004700
47014701
Examples
4702-
---------
4702+
--------
47034703
This is a method on all index types. For example you can do:
47044704
47054705
>>> idx = pd.Index(list('abcd'))
@@ -4902,7 +4902,7 @@ def slice_locs(self, start=None, end=None, step=None, kind=None):
49024902
This method only works if the index is monotonic or unique.
49034903
49044904
Examples
4905-
---------
4905+
--------
49064906
>>> idx = pd.Index(list('abcd'))
49074907
>>> idx.slice_locs(start='b', end='c')
49084908
(1, 3)

pandas/core/indexes/category.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def get_loc(self, key, method=None):
474474
KeyError : if the key is not in the index
475475
476476
Examples
477-
---------
477+
--------
478478
>>> unique_index = pd.CategoricalIndex(list('abc'))
479479
>>> unique_index.get_loc('b')
480480
1

pandas/core/indexes/datetimes.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -204,21 +204,21 @@ class DatetimeIndex(DatetimeIndexOpsMixin, Int64Index, DatetimeDelegateMixin):
204204
month_name
205205
day_name
206206
207+
See Also
208+
--------
209+
Index : The base pandas Index type.
210+
TimedeltaIndex : Index of timedelta64 data.
211+
PeriodIndex : Index of Period data.
212+
to_datetime : Convert argument to datetime.
213+
date_range : Create a fixed-frequency DatetimeIndex.
214+
207215
Notes
208216
-----
209217
To learn more about the frequency strings, please see `this link
210218
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
211219
212220
Creating a DatetimeIndex based on `start`, `periods`, and `end` has
213221
been deprecated in favor of :func:`date_range`.
214-
215-
See Also
216-
---------
217-
Index : The base pandas Index type.
218-
TimedeltaIndex : Index of timedelta64 data.
219-
PeriodIndex : Index of Period data.
220-
to_datetime : Convert argument to datetime.
221-
date_range : Create a fixed-frequency DatetimeIndex.
222222
"""
223223
_typ = 'datetimeindex'
224224
_join_precedence = 10

pandas/core/indexes/interval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ def get_loc(self, key, method=None):
729729
loc : int if unique index, slice if monotonic index, else mask
730730
731731
Examples
732-
---------
732+
--------
733733
>>> i1, i2 = pd.Interval(0, 1), pd.Interval(1, 2)
734734
>>> index = pd.IntervalIndex([i1, i2])
735735
>>> index.get_loc(1)

pandas/core/indexes/multi.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _codes_to_ints(self, codes):
5757
Combinations of integers (one per row)
5858
5959
Returns
60-
------
60+
-------
6161
int_keys : scalar or 1-dimensional array, of dtype uint64
6262
Integer(s) representing one combination (each).
6363
"""
@@ -97,7 +97,7 @@ def _codes_to_ints(self, codes):
9797
Combinations of integers (one per row)
9898
9999
Returns
100-
------
100+
-------
101101
int_keys : int, or 1-dimensional array of dtype object
102102
Integer(s) representing one combination (each).
103103
"""
@@ -179,8 +179,13 @@ class MultiIndex(Index):
179179
MultiIndex.from_frame : Make a MultiIndex from a DataFrame.
180180
Index : The base pandas Index type.
181181
182+
Notes
183+
-----
184+
See the `user guide
185+
<http://pandas.pydata.org/pandas-docs/stable/advanced.html>`_ for more.
186+
182187
Examples
183-
---------
188+
--------
184189
A new ``MultiIndex`` is typically constructed using one of the helper
185190
methods :meth:`MultiIndex.from_arrays`, :meth:`MultiIndex.from_product`
186191
and :meth:`MultiIndex.from_tuples`. For example (using ``.from_arrays``):
@@ -193,11 +198,6 @@ class MultiIndex(Index):
193198
194199
See further examples for how to construct a MultiIndex in the doc strings
195200
of the mentioned helper methods.
196-
197-
Notes
198-
-----
199-
See the `user guide
200-
<http://pandas.pydata.org/pandas-docs/stable/advanced.html>`_ for more.
201201
"""
202202

203203
# initialize to zero-length tuples to make everything work
@@ -1398,7 +1398,7 @@ def get_level_values(self, level):
13981398
a single :class:`Index` (or subclass thereof).
13991399
14001400
Examples
1401-
---------
1401+
--------
14021402
14031403
Create a MultiIndex:
14041404
@@ -2367,29 +2367,29 @@ def get_loc(self, key, method=None):
23672367
If the key is past the lexsort depth, the return may be a
23682368
boolean mask array, otherwise it is always a slice or int.
23692369
2370+
See Also
2371+
--------
2372+
Index.get_loc : The get_loc method for (single-level) index.
2373+
MultiIndex.slice_locs : Get slice location given start label(s) and
2374+
end label(s).
2375+
MultiIndex.get_locs : Get location for a label/slice/list/mask or a
2376+
sequence of such.
2377+
2378+
Notes
2379+
-----
2380+
The key cannot be a slice, list of same-level labels, a boolean mask,
2381+
or a sequence of such. If you want to use those, use
2382+
:meth:`MultiIndex.get_locs` instead.
2383+
23702384
Examples
2371-
---------
2385+
--------
23722386
>>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')])
23732387
23742388
>>> mi.get_loc('b')
23752389
slice(1, 3, None)
23762390
23772391
>>> mi.get_loc(('b', 'e'))
23782392
1
2379-
2380-
Notes
2381-
------
2382-
The key cannot be a slice, list of same-level labels, a boolean mask,
2383-
or a sequence of such. If you want to use those, use
2384-
:meth:`MultiIndex.get_locs` instead.
2385-
2386-
See Also
2387-
--------
2388-
Index.get_loc : The get_loc method for (single-level) index.
2389-
MultiIndex.slice_locs : Get slice location given start label(s) and
2390-
end label(s).
2391-
MultiIndex.get_locs : Get location for a label/slice/list/mask or a
2392-
sequence of such.
23932393
"""
23942394
if method is not None:
23952395
raise NotImplementedError('only the default get_loc method is '
@@ -2470,6 +2470,12 @@ def get_loc_level(self, key, level=0, drop_level=True):
24702470
Element 1: The resulting sliced multiindex/index. If the key
24712471
contains all levels, this will be ``None``.
24722472
2473+
See Also
2474+
--------
2475+
MultiIndex.get_loc : Get location for a label or a tuple of labels.
2476+
MultiIndex.get_locs : Get location for a label/slice/list/mask or a
2477+
sequence of such.
2478+
24732479
Examples
24742480
--------
24752481
>>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')],
@@ -2484,12 +2490,6 @@ def get_loc_level(self, key, level=0, drop_level=True):
24842490
24852491
>>> mi.get_loc_level(['b', 'e'])
24862492
(1, None)
2487-
2488-
See Also
2489-
---------
2490-
MultiIndex.get_loc : Get location for a label or a tuple of labels.
2491-
MultiIndex.get_locs : Get location for a label/slice/list/mask or a
2492-
sequence of such.
24932493
"""
24942494

24952495
def maybe_droplevels(indexer, levels, drop_level):
@@ -2698,7 +2698,7 @@ def get_locs(self, seq):
26982698
locs : array of integers suitable for passing to iloc
26992699
27002700
Examples
2701-
---------
2701+
--------
27022702
>>> mi = pd.MultiIndex.from_arrays([list('abb'), list('def')])
27032703
27042704
>>> mi.get_locs('b')

pandas/core/indexes/period.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin):
144144
strftime
145145
to_timestamp
146146
147+
See Also
148+
--------
149+
Index : The base pandas Index type.
150+
Period : Represents a period of time.
151+
DatetimeIndex : Index with datetime64 data.
152+
TimedeltaIndex : Index of timedelta64 data.
153+
period_range : Create a fixed-frequency PeriodIndex.
154+
147155
Notes
148156
-----
149157
Creating a PeriodIndex based on `start`, `periods`, and `end` has
@@ -152,14 +160,6 @@ class PeriodIndex(DatetimeIndexOpsMixin, Int64Index, PeriodDelegateMixin):
152160
Examples
153161
--------
154162
>>> idx = pd.PeriodIndex(year=year_arr, quarter=q_arr)
155-
156-
See Also
157-
---------
158-
Index : The base pandas Index type.
159-
Period : Represents a period of time.
160-
DatetimeIndex : Index with datetime64 data.
161-
TimedeltaIndex : Index of timedelta64 data.
162-
period_range : Create a fixed-frequency PeriodIndex.
163163
"""
164164
_typ = 'periodindex'
165165
_attributes = ['name', 'freq']

pandas/core/indexes/timedeltas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class TimedeltaIndex(DatetimeIndexOpsMixin, dtl.TimelikeOps, Int64Index,
131131
to_frame
132132
133133
See Also
134-
---------
134+
--------
135135
Index : The base pandas Index type.
136136
Timedelta : Represents a duration between two dates or times.
137137
DatetimeIndex : Index of datetime64 data.

pandas/core/indexing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,8 @@ def _align_series(self, indexer, ser, multiindex_indexer=False):
670670
a `pd.MultiIndex`, to avoid unnecessary broadcasting.
671671
672672
673-
Returns:
674-
--------
673+
Returns
674+
-------
675675
`np.array` of `ser` broadcast to the appropriate shape for assignment
676676
to the locations selected by `indexer`
677677

0 commit comments

Comments
 (0)