Skip to content

Commit b9b081d

Browse files
killerontherun1jreback
authored andcommitted
Docstring GL01 GL02 fixes (#26526)
1 parent 4850b28 commit b9b081d

File tree

14 files changed

+57
-33
lines changed

14 files changed

+57
-33
lines changed

pandas/core/accessor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def decorator(accessor):
196196
return decorator
197197

198198

199-
_doc = """\
199+
_doc = """
200200
Register a custom accessor on %(klass)s objects.
201201
202202
Parameters

pandas/core/arrays/categorical.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def contains(cat, key, container):
196196
return any(loc_ in container for loc_ in loc)
197197

198198

199-
_codes_doc = """\
199+
_codes_doc = """
200200
The category codes of this categorical.
201201
202202
Level codes are an array if integer which are the positions of the real

pandas/core/arrays/interval.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ def __array__(self, dtype=None):
987987
result[i] = Interval(left[i], right[i], closed)
988988
return result
989989

990-
_interval_shared_docs['to_tuples'] = """\
990+
_interval_shared_docs['to_tuples'] = """
991991
Return an %(return_type)s of tuples of the form (left, right)
992992
993993
Parameters
@@ -1002,7 +1002,7 @@ def __array__(self, dtype=None):
10021002
-------
10031003
tuples: %(return_type)s
10041004
%(examples)s\
1005-
"""
1005+
"""
10061006

10071007
@Appender(_interval_shared_docs['to_tuples'] % dict(
10081008
return_type='ndarray',

pandas/core/base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -638,8 +638,8 @@ def _is_builtin_func(self, arg):
638638

639639

640640
class IndexOpsMixin:
641-
""" common ops mixin to support a unified interface / docs for Series /
642-
Index
641+
"""
642+
Common ops mixin to support a unified interface / docs for Series / Index
643643
"""
644644

645645
# ndarray compatibility
@@ -656,8 +656,8 @@ def transpose(self, *args, **kwargs):
656656
nv.validate_transpose(args, kwargs)
657657
return self
658658

659-
T = property(transpose, doc="Return the transpose, which is by "
660-
"definition self.")
659+
T = property(transpose, doc="""\nReturn the transpose, which is by
660+
definition self.\n""")
661661

662662
@property
663663
def _is_homogeneous_type(self):

pandas/core/computation/eval.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22

3-
"""Top level ``eval`` module.
3+
"""
4+
Top level ``eval`` module.
45
"""
56

67
import tokenize
@@ -15,7 +16,8 @@
1516

1617

1718
def _check_engine(engine):
18-
"""Make sure a valid engine is passed.
19+
"""
20+
Make sure a valid engine is passed.
1921
2022
Parameters
2123
----------
@@ -31,7 +33,6 @@ def _check_engine(engine):
3133
Returns
3234
-------
3335
string engine
34-
3536
"""
3637
from pandas.core.computation.check import _NUMEXPR_INSTALLED
3738

@@ -60,7 +61,8 @@ def _check_engine(engine):
6061

6162

6263
def _check_parser(parser):
63-
"""Make sure a valid parser is passed.
64+
"""
65+
Make sure a valid parser is passed.
6466
6567
Parameters
6668
----------
@@ -88,7 +90,8 @@ def _check_resolvers(resolvers):
8890

8991

9092
def _check_expression(expr):
91-
"""Make sure an expression is not an empty string
93+
"""
94+
Make sure an expression is not an empty string
9295
9396
Parameters
9497
----------
@@ -105,7 +108,8 @@ def _check_expression(expr):
105108

106109

107110
def _convert_expression(expr):
108-
"""Convert an object to an expression.
111+
"""
112+
Convert an object to an expression.
109113
110114
Thus function converts an object to an expression (a unicode string) and
111115
checks to make sure it isn't empty after conversion. This is used to
@@ -155,7 +159,8 @@ def _check_for_locals(expr, stack_level, parser):
155159
def eval(expr, parser='pandas', engine=None, truediv=True,
156160
local_dict=None, global_dict=None, resolvers=(), level=0,
157161
target=None, inplace=False):
158-
"""Evaluate a Python expression as a string using various backends.
162+
"""
163+
Evaluate a Python expression as a string using various backends.
159164
160165
The following arithmetic operations are supported: ``+``, ``-``, ``*``,
161166
``/``, ``**``, ``%``, ``//`` (python engine only) along with the following

pandas/core/dtypes/dtypes.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -631,12 +631,16 @@ def __init__(self, unit="ns", tz=None):
631631

632632
@property
633633
def unit(self):
634-
"""The precision of the datetime data."""
634+
"""
635+
The precision of the datetime data.
636+
"""
635637
return self._unit
636638

637639
@property
638640
def tz(self):
639-
"""The timezone."""
641+
"""
642+
The timezone.
643+
"""
640644
return self._tz
641645

642646
@classmethod
@@ -777,7 +781,9 @@ def __new__(cls, freq=None):
777781

778782
@property
779783
def freq(self):
780-
"""The frequency object of this PeriodDtype."""
784+
"""
785+
The frequency object of this PeriodDtype.
786+
"""
781787
return self._freq
782788

783789
@classmethod
@@ -944,7 +950,9 @@ def __new__(cls, subtype=None):
944950

945951
@property
946952
def subtype(self):
947-
"""The dtype of the Interval bounds."""
953+
"""
954+
The dtype of the Interval bounds.
955+
"""
948956
return self._subtype
949957

950958
@classmethod

pandas/core/dtypes/inference.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,8 @@ def is_named_tuple(obj):
427427

428428

429429
def is_hashable(obj):
430-
"""Return True if hash(obj) will succeed, False otherwise.
430+
"""
431+
Return True if hash(obj) will succeed, False otherwise.
431432
432433
Some types will pass a test against collections.abc.Hashable but fail when
433434
they are actually hashed with hash().

pandas/core/generic.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,8 @@ def __iter__(self):
18381838

18391839
# can we get a better explanation of this?
18401840
def keys(self):
1841-
"""Get the 'info axis' (see Indexing for more)
1841+
"""
1842+
Get the 'info axis' (see Indexing for more)
18421843
18431844
This is index for Series, columns for DataFrame.
18441845
@@ -1850,7 +1851,8 @@ def keys(self):
18501851
return self._info_axis
18511852

18521853
def iteritems(self):
1853-
"""Iterate over (label, values) on info axis
1854+
"""
1855+
Iterate over (label, values) on info axis
18541856
18551857
This is index for Series, columns for DataFrame and so on.
18561858
"""

pandas/core/groupby/groupby.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class providing the base-class of operations.
172172
{examples}
173173
""")
174174

175-
_pipe_template = """\
175+
_pipe_template = """
176176
Apply a function `func` with arguments to this %(klass)s object and return
177177
the function's result.
178178
@@ -223,7 +223,8 @@ class providing the base-class of operations.
223223
224224
Examples
225225
--------
226-
%(examples)s"""
226+
%(examples)s
227+
"""
227228

228229
_transform_template = """
229230
Call function producing a like-indexed %(klass)s on each group and

pandas/core/indexes/interval.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,8 @@ def _find_non_overlapping_monotonic_bounds(self, key):
769769
return start, stop
770770

771771
def get_loc(self, key, method=None):
772-
"""Get integer location, slice or boolean mask for requested label.
772+
"""
773+
Get integer location, slice or boolean mask for requested label.
773774
774775
Parameters
775776
----------

pandas/core/indexes/multi.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ def _set_names(self, names, level=None, validate=True):
11491149
self.levels[l].rename(name, inplace=True)
11501150

11511151
names = property(fset=_set_names, fget=_get_names,
1152-
doc="Names of levels in MultiIndex")
1152+
doc="""\nNames of levels in MultiIndex\n""")
11531153

11541154
@Appender(_index_shared_docs['_get_grouper_for_level'])
11551155
def _get_grouper_for_level(self, mapper, level):
@@ -1823,12 +1823,16 @@ def remove_unused_levels(self):
18231823

18241824
@property
18251825
def nlevels(self):
1826-
"""Integer number of levels in this MultiIndex."""
1826+
"""
1827+
Integer number of levels in this MultiIndex.
1828+
"""
18271829
return len(self.levels)
18281830

18291831
@property
18301832
def levshape(self):
1831-
"""A tuple with the length of each level."""
1833+
"""
1834+
A tuple with the length of each level.
1835+
"""
18321836
return tuple(len(x) for x in self.levels)
18331837

18341838
def __reduce__(self):

pandas/core/indexing.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,8 @@ def _get_slice_axis(self, slice_obj, axis=None):
13111311

13121312

13131313
class _IXIndexer(_NDFrameIndexer):
1314-
"""A primarily label-location based indexer, with integer position
1314+
"""
1315+
A primarily label-location based indexer, with integer position
13151316
fallback.
13161317
13171318
Warning: Starting in 0.20.0, the .ix indexer is deprecated, in

pandas/core/resample.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ def _assure_grouper(self):
204204
>>> df.resample('2D').pipe(lambda x: x.max() - x.min())
205205
A
206206
2012-08-02 1
207-
2012-08-04 1
208-
""")
207+
2012-08-04 1""")
209208
@Appender(_pipe_template)
210209
def pipe(self, func, *args, **kwargs):
211210
return super().pipe(func, *args, **kwargs)

pandas/core/reshape/merge.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ def merge_ordered(left, right, on=None,
133133
left_by=None, right_by=None,
134134
fill_method=None, suffixes=('_x', '_y'),
135135
how='outer'):
136-
"""Perform merge with optional filling/interpolation designed for ordered
136+
"""
137+
Perform merge with optional filling/interpolation designed for ordered
137138
data like time series data. Optionally perform group-wise merge (see
138139
examples)
139140
@@ -240,7 +241,8 @@ def merge_asof(left, right, on=None,
240241
tolerance=None,
241242
allow_exact_matches=True,
242243
direction='backward'):
243-
"""Perform an asof merge. This is similar to a left-join except that we
244+
"""
245+
Perform an asof merge. This is similar to a left-join except that we
244246
match on nearest key rather than equal keys.
245247
246248
Both DataFrames must be sorted by the key.

0 commit comments

Comments
 (0)