diff --git a/pandas/core/accessor.py b/pandas/core/accessor.py index 4353e0b3edd08..b092541da93e6 100644 --- a/pandas/core/accessor.py +++ b/pandas/core/accessor.py @@ -196,7 +196,7 @@ def decorator(accessor): return decorator -_doc = """\ +_doc = """ Register a custom accessor on %(klass)s objects. Parameters diff --git a/pandas/core/arrays/categorical.py b/pandas/core/arrays/categorical.py index c079b860bb924..155638aca5560 100644 --- a/pandas/core/arrays/categorical.py +++ b/pandas/core/arrays/categorical.py @@ -196,7 +196,7 @@ def contains(cat, key, container): return any(loc_ in container for loc_ in loc) -_codes_doc = """\ +_codes_doc = """ The category codes of this categorical. Level codes are an array if integer which are the positions of the real diff --git a/pandas/core/arrays/interval.py b/pandas/core/arrays/interval.py index 4f628eff43167..71f4cbae7c58d 100644 --- a/pandas/core/arrays/interval.py +++ b/pandas/core/arrays/interval.py @@ -987,7 +987,7 @@ def __array__(self, dtype=None): result[i] = Interval(left[i], right[i], closed) return result - _interval_shared_docs['to_tuples'] = """\ + _interval_shared_docs['to_tuples'] = """ Return an %(return_type)s of tuples of the form (left, right) Parameters @@ -1002,7 +1002,7 @@ def __array__(self, dtype=None): ------- tuples: %(return_type)s %(examples)s\ - """ + """ @Appender(_interval_shared_docs['to_tuples'] % dict( return_type='ndarray', diff --git a/pandas/core/base.py b/pandas/core/base.py index e4274e48d3227..ab9d8b9d778e5 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -638,8 +638,8 @@ def _is_builtin_func(self, arg): class IndexOpsMixin: - """ common ops mixin to support a unified interface / docs for Series / - Index + """ + Common ops mixin to support a unified interface / docs for Series / Index """ # ndarray compatibility @@ -656,8 +656,8 @@ def transpose(self, *args, **kwargs): nv.validate_transpose(args, kwargs) return self - T = property(transpose, doc="Return the transpose, which is by " - "definition self.") + T = property(transpose, doc="""\nReturn the transpose, which is by + definition self.\n""") @property def _is_homogeneous_type(self): diff --git a/pandas/core/computation/eval.py b/pandas/core/computation/eval.py index 8f6c271af4a58..ef4639a3afe4c 100644 --- a/pandas/core/computation/eval.py +++ b/pandas/core/computation/eval.py @@ -1,6 +1,7 @@ #!/usr/bin/env python -"""Top level ``eval`` module. +""" +Top level ``eval`` module. """ import tokenize @@ -15,7 +16,8 @@ def _check_engine(engine): - """Make sure a valid engine is passed. + """ + Make sure a valid engine is passed. Parameters ---------- @@ -31,7 +33,6 @@ def _check_engine(engine): Returns ------- string engine - """ from pandas.core.computation.check import _NUMEXPR_INSTALLED @@ -60,7 +61,8 @@ def _check_engine(engine): def _check_parser(parser): - """Make sure a valid parser is passed. + """ + Make sure a valid parser is passed. Parameters ---------- @@ -88,7 +90,8 @@ def _check_resolvers(resolvers): def _check_expression(expr): - """Make sure an expression is not an empty string + """ + Make sure an expression is not an empty string Parameters ---------- @@ -105,7 +108,8 @@ def _check_expression(expr): def _convert_expression(expr): - """Convert an object to an expression. + """ + Convert an object to an expression. Thus function converts an object to an expression (a unicode string) and 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): def eval(expr, parser='pandas', engine=None, truediv=True, local_dict=None, global_dict=None, resolvers=(), level=0, target=None, inplace=False): - """Evaluate a Python expression as a string using various backends. + """ + Evaluate a Python expression as a string using various backends. The following arithmetic operations are supported: ``+``, ``-``, ``*``, ``/``, ``**``, ``%``, ``//`` (python engine only) along with the following diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index a56ee72cf1910..7fe8ce7d71683 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -631,12 +631,16 @@ def __init__(self, unit="ns", tz=None): @property def unit(self): - """The precision of the datetime data.""" + """ + The precision of the datetime data. + """ return self._unit @property def tz(self): - """The timezone.""" + """ + The timezone. + """ return self._tz @classmethod @@ -777,7 +781,9 @@ def __new__(cls, freq=None): @property def freq(self): - """The frequency object of this PeriodDtype.""" + """ + The frequency object of this PeriodDtype. + """ return self._freq @classmethod @@ -944,7 +950,9 @@ def __new__(cls, subtype=None): @property def subtype(self): - """The dtype of the Interval bounds.""" + """ + The dtype of the Interval bounds. + """ return self._subtype @classmethod diff --git a/pandas/core/dtypes/inference.py b/pandas/core/dtypes/inference.py index 63cb4d85ca308..02ee777bbe7f3 100644 --- a/pandas/core/dtypes/inference.py +++ b/pandas/core/dtypes/inference.py @@ -427,7 +427,8 @@ def is_named_tuple(obj): def is_hashable(obj): - """Return True if hash(obj) will succeed, False otherwise. + """ + Return True if hash(obj) will succeed, False otherwise. Some types will pass a test against collections.abc.Hashable but fail when they are actually hashed with hash(). diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 903fd7ffe706a..fd890dcf9cd93 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -1832,7 +1832,8 @@ def __iter__(self): # can we get a better explanation of this? def keys(self): - """Get the 'info axis' (see Indexing for more) + """ + Get the 'info axis' (see Indexing for more) This is index for Series, columns for DataFrame. @@ -1844,7 +1845,8 @@ def keys(self): return self._info_axis def iteritems(self): - """Iterate over (label, values) on info axis + """ + Iterate over (label, values) on info axis This is index for Series, columns for DataFrame and so on. """ diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index 2b190c53da53d..43950f2f503c8 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -172,7 +172,7 @@ class providing the base-class of operations. {examples} """) -_pipe_template = """\ +_pipe_template = """ Apply a function `func` with arguments to this %(klass)s object and return the function's result. @@ -223,7 +223,8 @@ class providing the base-class of operations. Examples -------- -%(examples)s""" +%(examples)s +""" _transform_template = """ Call function producing a like-indexed %(klass)s on each group and diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index 24fcb32d09d27..d5467134f1413 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -769,7 +769,8 @@ def _find_non_overlapping_monotonic_bounds(self, key): return start, stop def get_loc(self, key, method=None): - """Get integer location, slice or boolean mask for requested label. + """ + Get integer location, slice or boolean mask for requested label. Parameters ---------- diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index 9217b388ce86b..0d31276102b3a 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -1119,7 +1119,7 @@ def _set_names(self, names, level=None, validate=True): self.levels[l].rename(name, inplace=True) names = property(fset=_set_names, fget=_get_names, - doc="Names of levels in MultiIndex") + doc="""\nNames of levels in MultiIndex\n""") @Appender(_index_shared_docs['_get_grouper_for_level']) def _get_grouper_for_level(self, mapper, level): @@ -1773,12 +1773,16 @@ def remove_unused_levels(self): @property def nlevels(self): - """Integer number of levels in this MultiIndex.""" + """ + Integer number of levels in this MultiIndex. + """ return len(self.levels) @property def levshape(self): - """A tuple with the length of each level.""" + """ + A tuple with the length of each level. + """ return tuple(len(x) for x in self.levels) def __reduce__(self): diff --git a/pandas/core/indexing.py b/pandas/core/indexing.py index 7f4827be6dff7..6a21adb1d16ae 100755 --- a/pandas/core/indexing.py +++ b/pandas/core/indexing.py @@ -1311,7 +1311,8 @@ def _get_slice_axis(self, slice_obj, axis=None): class _IXIndexer(_NDFrameIndexer): - """A primarily label-location based indexer, with integer position + """ + A primarily label-location based indexer, with integer position fallback. Warning: Starting in 0.20.0, the .ix indexer is deprecated, in diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 874973846a006..d1d99d28e59b6 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -204,8 +204,7 @@ def _assure_grouper(self): >>> df.resample('2D').pipe(lambda x: x.max() - x.min()) A 2012-08-02 1 - 2012-08-04 1 - """) + 2012-08-04 1""") @Appender(_pipe_template) def pipe(self, func, *args, **kwargs): return super().pipe(func, *args, **kwargs) diff --git a/pandas/core/reshape/merge.py b/pandas/core/reshape/merge.py index 1a80b35629356..d21ad58e752c2 100644 --- a/pandas/core/reshape/merge.py +++ b/pandas/core/reshape/merge.py @@ -133,7 +133,8 @@ def merge_ordered(left, right, on=None, left_by=None, right_by=None, fill_method=None, suffixes=('_x', '_y'), how='outer'): - """Perform merge with optional filling/interpolation designed for ordered + """ + Perform merge with optional filling/interpolation designed for ordered data like time series data. Optionally perform group-wise merge (see examples) @@ -240,7 +241,8 @@ def merge_asof(left, right, on=None, tolerance=None, allow_exact_matches=True, direction='backward'): - """Perform an asof merge. This is similar to a left-join except that we + """ + Perform an asof merge. This is similar to a left-join except that we match on nearest key rather than equal keys. Both DataFrames must be sorted by the key.