From e4153254f1d1af6caed06c46fb73a55999c1d817 Mon Sep 17 00:00:00 2001 From: Prabakaran Kumaresshan Date: Sat, 24 Nov 2018 23:59:38 +0530 Subject: [PATCH] DOC: Capitalize docstring summaries Fixes #23881 --- pandas/_libs/tslibs/timedeltas.pyx | 12 +++++--- pandas/_libs/tslibs/timestamps.pyx | 8 ++--- pandas/core/frame.py | 2 +- pandas/core/groupby/groupby.py | 8 +++-- pandas/core/indexes/base.py | 49 ++++++++++++++++++------------ pandas/core/indexes/multi.py | 4 +-- pandas/core/indexes/range.py | 8 +++-- pandas/core/resample.py | 10 +++--- pandas/core/window.py | 2 +- pandas/io/json/normalize.py | 2 +- pandas/io/pytables.py | 2 +- 11 files changed, 63 insertions(+), 44 deletions(-) diff --git a/pandas/_libs/tslibs/timedeltas.pyx b/pandas/_libs/tslibs/timedeltas.pyx index 4d612a6f43107..09b66bba61018 100644 --- a/pandas/_libs/tslibs/timedeltas.pyx +++ b/pandas/_libs/tslibs/timedeltas.pyx @@ -97,8 +97,8 @@ _no_input = object() @cython.wraparound(False) def ints_to_pytimedelta(int64_t[:] arr, box=False): """ - convert an i8 repr to an ndarray of timedelta or Timedelta (if box == - True) + Convert an i8 repr to an ndarray of timedelta or Timedelta (if box == + True). Parameters ---------- @@ -823,7 +823,9 @@ cdef class _Timedelta(timedelta): return self.value / 1e9 def view(self, dtype): - """ array view compat """ + """ + Array view compat. + """ return np.timedelta64(self.value).view(dtype) @property @@ -1226,7 +1228,7 @@ class Timedelta(_Timedelta): def floor(self, freq): """ - return a new Timedelta floored to this resolution + Return a new Timedelta floored to this resolution. Parameters ---------- @@ -1236,7 +1238,7 @@ class Timedelta(_Timedelta): def ceil(self, freq): """ - return a new Timedelta ceiled to this resolution + Return a new Timedelta ceiled to this resolution. Parameters ---------- diff --git a/pandas/_libs/tslibs/timestamps.pyx b/pandas/_libs/tslibs/timestamps.pyx index bb7a9a57b8a75..75c4d3c137a44 100644 --- a/pandas/_libs/tslibs/timestamps.pyx +++ b/pandas/_libs/tslibs/timestamps.pyx @@ -579,7 +579,7 @@ class Timestamp(_Timestamp): """ Timestamp.fromordinal(ordinal, freq=None, tz=None) - passed an ordinal, translate and convert to a ts + Passed an ordinal, translate and convert to a ts. note: by definition there cannot be any tz info on the ordinal itself Parameters @@ -802,7 +802,7 @@ class Timestamp(_Timestamp): def floor(self, freq, ambiguous='raise', nonexistent='raise'): """ - return a new Timestamp floored to this resolution + Return a new Timestamp floored to this resolution. Parameters ---------- @@ -834,7 +834,7 @@ class Timestamp(_Timestamp): def ceil(self, freq, ambiguous='raise', nonexistent='raise'): """ - return a new Timestamp ceiled to this resolution + Return a new Timestamp ceiled to this resolution. Parameters ---------- @@ -1148,7 +1148,7 @@ class Timestamp(_Timestamp): hour=None, minute=None, second=None, microsecond=None, nanosecond=None, tzinfo=object, fold=0): """ - implements datetime.replace, handles nanoseconds + Implements datetime.replace, handles nanoseconds. Parameters ---------- diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 8d089ab3a1949..849f322a9d7b4 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -1953,7 +1953,7 @@ def to_stata(self, fname, convert_dates=None, write_index=True, def to_feather(self, fname): """ - write out the binary feather-format for DataFrames + Write out the binary feather-format for DataFrames .. versionadded:: 0.20.0 diff --git a/pandas/core/groupby/groupby.py b/pandas/core/groupby/groupby.py index b68fdf853ab19..98df64235d866 100644 --- a/pandas/core/groupby/groupby.py +++ b/pandas/core/groupby/groupby.py @@ -384,7 +384,9 @@ def _assure_grouper(self): @property def groups(self): - """ dict {group name -> group labels} """ + """ + Dict {group name -> group labels}. + """ self._assure_grouper() return self.grouper.groups @@ -395,7 +397,9 @@ def ngroups(self): @property def indices(self): - """ dict {group name -> group indices} """ + """ + Dict {group name -> group indices} + """ self._assure_grouper() return self.grouper.indices diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index 28aefb652adb0..ab848451f93e8 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -690,17 +690,23 @@ def __array_wrap__(self, result, context=None): @cache_readonly def dtype(self): - """ return the dtype object of the underlying data """ + """ + Return the dtype object of the underlying data. + """ return self._data.dtype @cache_readonly def dtype_str(self): - """ return the dtype str of the underlying data """ + """ + Return the dtype str of the underlying data. + """ return str(self.dtype) @property def values(self): - """ return the underlying data as an ndarray """ + """ + Return the underlying data as an ndarray. + """ return self._data.view(np.ndarray) @property @@ -825,12 +831,12 @@ def repeat(self, repeats, *args, **kwargs): return self._shallow_copy(self._values.repeat(repeats)) _index_shared_docs['where'] = """ - .. versionadded:: 0.19.0 - Return an Index of same shape as self and whose corresponding entries are from self where cond is True and otherwise are from other. + .. versionadded:: 0.19.0 + Parameters ---------- cond : boolean array-like with the same length as self @@ -862,7 +868,7 @@ def where(self, cond, other=None): def ravel(self, order='C'): """ - return an ndarray of the flattened values of the underlying data + Return an ndarray of the flattened values of the underlying data See Also -------- @@ -1124,7 +1130,7 @@ def to_flat_index(self): def to_series(self, index=None, name=None): """ Create a Series with both index and values equal to the index keys - useful with map for returning an indexer based on an index + useful with map for returning an indexer based on an index. Parameters ---------- @@ -1493,13 +1499,15 @@ def _mpl_repr(self): # introspection @property def is_monotonic(self): - """ alias for is_monotonic_increasing (deprecated) """ + """ + Alias for is_monotonic_increasing (deprecated). + """ return self.is_monotonic_increasing @property def is_monotonic_increasing(self): """ - return if the index is monotonic increasing (only equal or + Return if the index is monotonic increasing (only equal or increasing) values. Examples @@ -1516,7 +1524,7 @@ def is_monotonic_increasing(self): @property def is_monotonic_decreasing(self): """ - return if the index is monotonic decreasing (only equal or + Return if the index is monotonic decreasing (only equal or decreasing) values. Examples @@ -1567,7 +1575,9 @@ def is_lexsorted_for_tuple(self, tup): @cache_readonly def is_unique(self): - """ return if the index has unique values """ + """ + Return if the index has unique values. + """ return self._engine.is_unique @property @@ -1958,7 +1968,7 @@ def _get_level_number(self, level): @cache_readonly def inferred_type(self): - """ return a string of the type inferred from the values """ + """ Return a string of the type inferred from the values. """ return lib.infer_dtype(self) def _is_memory_usage_qualified(self): @@ -2034,7 +2044,7 @@ def __contains__(self, key): return False _index_shared_docs['contains'] = """ - return a boolean if this key is IN the index + Return a boolean if this key is IN the index. Parameters ---------- @@ -2109,7 +2119,7 @@ def _can_hold_identifiers_and_holds_name(self, name): def append(self, other): """ - Append a collection of Index options together + Append a collection of Index options together. Parameters ---------- @@ -2152,7 +2162,7 @@ def _concat_same_dtype(self, to_concat, name): return _concat._concat_index_asobject(to_concat, name) _index_shared_docs['take'] = """ - return a new %(klass)s of the values selected by the indices + Return a new %(klass)s of the values selected by the indices. For internal compatibility with numpy arrays. @@ -2345,7 +2355,7 @@ def notna(self): def putmask(self, mask, value): """ - return a new Index of the values set with the mask + Return a new Index of the values set with the mask. See Also -------- @@ -2364,7 +2374,7 @@ def putmask(self, mask, value): def format(self, name=False, formatter=None, **kwargs): """ - Render a string representation of the Index + Render a string representation of the Index. """ header = [] if name: @@ -2461,8 +2471,9 @@ def equals(self, other): return False def identical(self, other): - """Similar to equals, but check that other comparable attributes are - also equal + """ + Similar to equals, but check that other comparable attributes are + also equal. """ return (self.equals(other) and all((getattr(self, c, None) == getattr(other, c, None) diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index f9483b48b5261..baf6f7f7a1bfd 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -1195,14 +1195,14 @@ def to_frame(self, index=True, name=None): def to_hierarchical(self, n_repeat, n_shuffle=1): """ - .. deprecated:: 0.24.0 - Return a MultiIndex reshaped to conform to the shapes given by n_repeat and n_shuffle. Useful to replicate and rearrange a MultiIndex for combination with another Index with n_repeat items. + .. deprecated:: 0.24.0 + Parameters ---------- n_repeat : int diff --git a/pandas/core/indexes/range.py b/pandas/core/indexes/range.py index 0d4e7aaebeca5..ae08738762a5d 100644 --- a/pandas/core/indexes/range.py +++ b/pandas/core/indexes/range.py @@ -122,7 +122,9 @@ def ensure_int(value, field): @classmethod def from_range(cls, data, name=None, dtype=None, **kwargs): - """ create RangeIndex from a range (py3), or xrange (py2) object """ + """ + Create RangeIndex from a range (py3), or xrange (py2) object. + """ if not isinstance(data, range): raise TypeError( '{0}(...) must be called with object coercible to a ' @@ -206,14 +208,14 @@ def nbytes(self): """ Return the number of bytes in the underlying data On implementations where this is undetermined (PyPy) - assume 24 bytes for each value + assume 24 bytes for each value. """ return sum(getsizeof(getattr(self, v), 24) for v in ['_start', '_stop', '_step']) def memory_usage(self, deep=False): """ - Memory usage of my values + Memory usage of my values. Parameters ---------- diff --git a/pandas/core/resample.py b/pandas/core/resample.py index 125b441e5558a..f1c1ce80873c9 100644 --- a/pandas/core/resample.py +++ b/pandas/core/resample.py @@ -394,7 +394,7 @@ def _wrap_result(self, result): def pad(self, limit=None): """ - Forward fill the values + Forward fill the values. Parameters ---------- @@ -757,8 +757,8 @@ def interpolate(self, method='linear', axis=0, limit=None, inplace=False, def asfreq(self, fill_value=None): """ - return the values at the new freq, - essentially a reindex + Return the values at the new freq, + essentially a reindex. Parameters ---------- @@ -777,7 +777,7 @@ def asfreq(self, fill_value=None): def std(self, ddof=1, *args, **kwargs): """ - Compute standard deviation of groups, excluding missing values + Compute standard deviation of groups, excluding missing values. Parameters ---------- @@ -789,7 +789,7 @@ def std(self, ddof=1, *args, **kwargs): def var(self, ddof=1, *args, **kwargs): """ - Compute variance of groups, excluding missing values + Compute variance of groups, excluding missing values. Parameters ---------- diff --git a/pandas/core/window.py b/pandas/core/window.py index 4c67b04e89ba8..da55eecea892b 100644 --- a/pandas/core/window.py +++ b/pandas/core/window.py @@ -995,7 +995,7 @@ def sum(self, *args, **kwargs): return self._apply('roll_sum', 'sum', **kwargs) _shared_docs['max'] = dedent(""" - %(name)s maximum + Calculate the %(name)s maximum. """) def max(self, *args, **kwargs): diff --git a/pandas/io/json/normalize.py b/pandas/io/json/normalize.py index 3e3f125b56d88..4d60d18ab8070 100644 --- a/pandas/io/json/normalize.py +++ b/pandas/io/json/normalize.py @@ -99,7 +99,7 @@ def json_normalize(data, record_path=None, meta=None, errors='raise', sep='.'): """ - "Normalize" semi-structured JSON data into a flat table + Normalize semi-structured JSON data into a flat table Parameters ---------- diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index ab1c89ef828d0..5195dfa4f816a 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -1217,7 +1217,7 @@ def copy(self, file, mode='w', propindexes=True, keys=None, complib=None, def info(self): """ - print detailed information on the store + Print detailed information on the store .. versionadded:: 0.21.0 """