From 95a6ac2030f56505c6cb3691bc9d0c242c635a54 Mon Sep 17 00:00:00 2001 From: Alex Volkov Date: Mon, 12 Nov 2018 13:25:58 -0500 Subject: [PATCH 01/13] Capitalizing first letter of doc in pandas.Series --- pandas/core/base.py | 28 ++++++++++++++-------------- pandas/core/generic.py | 2 +- pandas/core/series.py | 12 ++++++------ 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index de368f52b6f00..5245235e3fbaa 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -668,7 +668,7 @@ class IndexOpsMixin(object): __array_priority__ = 1000 def transpose(self, *args, **kwargs): - """ return the transpose, which is by definition self """ + """ Return the transpose, which is by definition self """ nv.validate_transpose(args, kwargs) return self @@ -692,18 +692,18 @@ def _is_homogeneous_type(self): @property def shape(self): - """ return a tuple of the shape of the underlying data """ + """ Return a tuple of the shape of the underlying data """ return self._values.shape @property def ndim(self): - """ return the number of dimensions of the underlying data, + """ Return the number of dimensions of the underlying data, by definition 1 """ return 1 def item(self): - """ return the first element of the underlying data as a python + """ Return the first element of the underlying data as a python scalar """ try: @@ -715,7 +715,7 @@ def item(self): @property def data(self): - """ return the data pointer of the underlying data """ + """ Return the data pointer of the underlying data """ warnings.warn("{obj}.data is deprecated and will be removed " "in a future version".format(obj=type(self).__name__), FutureWarning, stacklevel=2) @@ -723,7 +723,7 @@ def data(self): @property def itemsize(self): - """ return the size of the dtype of the item of the underlying data """ + """ Return the size of the dtype of the item of the underlying data """ warnings.warn("{obj}.itemsize is deprecated and will be removed " "in a future version".format(obj=type(self).__name__), FutureWarning, stacklevel=2) @@ -731,12 +731,12 @@ def itemsize(self): @property def nbytes(self): - """ return the number of bytes in the underlying data """ + """ Return the number of bytes in the underlying data """ return self._values.nbytes @property def strides(self): - """ return the strides of the underlying data """ + """ Return the strides of the underlying data """ warnings.warn("{obj}.strides is deprecated and will be removed " "in a future version".format(obj=type(self).__name__), FutureWarning, stacklevel=2) @@ -744,12 +744,12 @@ def strides(self): @property def size(self): - """ return the number of elements in the underlying data """ + """ Return the number of elements in the underlying data """ return self._values.size @property def flags(self): - """ return the ndarray.flags for the underlying data """ + """ Return the ndarray.flags for the underlying data """ warnings.warn("{obj}.flags is deprecated and will be removed " "in a future version".format(obj=type(self).__name__), FutureWarning, stacklevel=2) @@ -757,7 +757,7 @@ def flags(self): @property def base(self): - """ return the base object if the memory of the underlying data is + """ Return the base object if the memory of the underlying data is shared """ warnings.warn("{obj}.base is deprecated and will be removed " @@ -818,7 +818,7 @@ def max(self): def argmax(self, axis=None): """ - return a ndarray of the maximum argument indexer + Return a ndarray of the maximum argument indexer See also -------- @@ -861,7 +861,7 @@ def min(self): def argmin(self, axis=None): """ - return a ndarray of the minimum argument indexer + Return a ndarray of the minimum argument indexer See also -------- @@ -900,7 +900,7 @@ def __iter__(self): @cache_readonly def hasnans(self): - """ return if I have any nans; enables various perf speedups """ + """ Return if I have any nans; enables various perf speedups """ return bool(isna(self).any()) def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None, diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 34f25c5634d5b..9d98b534da37c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2328,7 +2328,7 @@ def to_hdf(self, path_or_buf, key, **kwargs): def to_msgpack(self, path_or_buf=None, encoding='utf-8', **kwargs): """ - msgpack (serialize) object to input file path + Serialize object to input file path using msgpack format THIS IS AN EXPERIMENTAL LIBRARY and the storage format may not be stable until a future release. diff --git a/pandas/core/series.py b/pandas/core/series.py index 20e4720a3bde7..6604cd390571e 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -390,22 +390,22 @@ def name(self, value): # ndarray compatibility @property def dtype(self): - """ return the dtype object of the underlying data """ + """ Return the dtype object of the underlying data """ return self._data.dtype @property def dtypes(self): - """ return the dtype object of the underlying data """ + """ Return the dtype object of the underlying data """ return self._data.dtype @property def ftype(self): - """ return if the data is sparse|dense """ + """ Return if the data is sparse|dense """ return self._data.ftype @property def ftypes(self): - """ return if the data is sparse|dense """ + """ Return if the data is sparse|dense """ return self._data.ftype @property @@ -443,7 +443,7 @@ def values(self): @property def _values(self): - """ return the internal repr of this data """ + """ Return the internal repr of this data """ return self._data.internal_values() def _formatting_values(self): @@ -453,7 +453,7 @@ def _formatting_values(self): return self._data.formatting_values() def get_values(self): - """ same as values (but handles sparseness conversions); is a view """ + """ Same as values (but handles sparseness conversions); is a view """ return self._data.get_values() @property From 09e2d07e566f75b24f510437a1771bdff08931c4 Mon Sep 17 00:00:00 2001 From: Alex Volkov Date: Mon, 12 Nov 2018 13:35:57 -0500 Subject: [PATCH 02/13] Documented SparseAccessor class. --- pandas/core/arrays/sparse.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/core/arrays/sparse.py b/pandas/core/arrays/sparse.py index 672261c2a407e..7ed0f1f0a4d94 100644 --- a/pandas/core/arrays/sparse.py +++ b/pandas/core/arrays/sparse.py @@ -1861,6 +1861,8 @@ def _make_index(length, indices, kind): 'sp_values'], typ='property') class SparseAccessor(PandasDelegate): + """ Accessor for SparseSparse from other sparse matrix data types """ + def __init__(self, data=None): self._validate(data) # Store the Series since we need that for to_coo From 0c6e1961afbde3b201938303259a81e7e9f7f764 Mon Sep 17 00:00:00 2001 From: Alex Volkov Date: Mon, 12 Nov 2018 14:12:04 -0500 Subject: [PATCH 03/13] Fixed docstring for pandas.Series.T --- pandas/core/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index 5245235e3fbaa..89d7c81413c2c 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -672,7 +672,7 @@ def transpose(self, *args, **kwargs): nv.validate_transpose(args, kwargs) return self - T = property(transpose, doc="return the transpose, which is by " + T = property(transpose, doc="Return the transpose, which is by " "definition self") @property From e787519b16516e11d0484d60ec266ac3abc35074 Mon Sep 17 00:00:00 2001 From: Alex Volkov Date: Mon, 12 Nov 2018 14:29:47 -0500 Subject: [PATCH 04/13] Fixed doc errors for Series.dt --- pandas/core/indexes/datetimelike.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index 1d9d3b1d3bd16..9f1e3def7acf9 100644 --- a/pandas/core/indexes/datetimelike.py +++ b/pandas/core/indexes/datetimelike.py @@ -80,7 +80,7 @@ class TimelikeOps(object): _round_doc = ( """ - {op} the data to the specified `freq`. + Perform {op} operation on the data to the specified `freq`. Parameters ---------- From c8cc936e8021b8982a34f74f2a11c5a8db8c6bc0 Mon Sep 17 00:00:00 2001 From: Alex Volkov Date: Mon, 12 Nov 2018 14:53:48 -0500 Subject: [PATCH 05/13] Fixing docstring errors found with ./scripts/validate_docstrings.py pandas.Series --- pandas/core/series.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pandas/core/series.py b/pandas/core/series.py index 6604cd390571e..e4261ad6e7dc2 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -118,7 +118,7 @@ class Series(base.IndexOpsMixin, generic.NDFrame): Parameters ---------- data : array-like, Iterable, dict, or scalar value - Contains data stored in Series + Contains data stored in Series. .. versionchanged :: 0.23.0 If data is a dict, argument order is maintained for Python 3.6 @@ -133,8 +133,8 @@ class Series(base.IndexOpsMixin, generic.NDFrame): dtype : str, numpy.dtype, or ExtensionDtype, optional dtype for the output Series. If not specified, this will be inferred from `data`. - copy : boolean, default False - Copy input data + copy : bool, default False + Copy input data. """ _metadata = ['name'] _accessors = {'dt', 'cat', 'str', 'sparse'} @@ -3453,9 +3453,9 @@ def rename(self, index=None, **kwargs): the index. Scalar or hashable sequence-like will alter the ``Series.name`` attribute. - copy : boolean, default True + copy : bool, default True Also copy underlying data - inplace : boolean, default False + inplace : bool, default False Whether to return a new Series. If True then value of copy is ignored. level : int or level name, default None From eeef46e5a67f6b4b889d171d3385f03962de7948 Mon Sep 17 00:00:00 2001 From: Alex Volkov Date: Mon, 12 Nov 2018 16:13:43 -0500 Subject: [PATCH 06/13] Updated return message doc strings. --- pandas/core/arrays/sparse.py | 4 ++- pandas/core/base.py | 52 ++++++++++++++++++++++++------------ pandas/core/series.py | 24 ++++++++++++----- 3 files changed, 56 insertions(+), 24 deletions(-) diff --git a/pandas/core/arrays/sparse.py b/pandas/core/arrays/sparse.py index 7ed0f1f0a4d94..24e33c32d0898 100644 --- a/pandas/core/arrays/sparse.py +++ b/pandas/core/arrays/sparse.py @@ -1861,7 +1861,9 @@ def _make_index(length, indices, kind): 'sp_values'], typ='property') class SparseAccessor(PandasDelegate): - """ Accessor for SparseSparse from other sparse matrix data types """ + """ + Accessor for SparseSparse from other sparse matrix data types. + """ def __init__(self, data=None): self._validate(data) diff --git a/pandas/core/base.py b/pandas/core/base.py index 89d7c81413c2c..0c7bf9da8ff03 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -668,7 +668,9 @@ class IndexOpsMixin(object): __array_priority__ = 1000 def transpose(self, *args, **kwargs): - """ Return the transpose, which is by definition self """ + """ + Return the transpose, which is by definition self. + """ nv.validate_transpose(args, kwargs) return self @@ -692,19 +694,21 @@ def _is_homogeneous_type(self): @property def shape(self): - """ Return a tuple of the shape of the underlying data """ + """ + Return a tuple of the shape of the underlying data. + """ return self._values.shape @property def ndim(self): - """ Return the number of dimensions of the underlying data, - by definition 1 + """ + Return the number of dimensions of the underlying data, by definition 1. """ return 1 def item(self): - """ Return the first element of the underlying data as a python - scalar + """ + Return the first element of the underlying data as a python scalar. """ try: return self.values.item() @@ -715,7 +719,9 @@ def item(self): @property def data(self): - """ Return the data pointer of the underlying data """ + """ + Return the data pointer of the underlying data. + """ warnings.warn("{obj}.data is deprecated and will be removed " "in a future version".format(obj=type(self).__name__), FutureWarning, stacklevel=2) @@ -723,7 +729,9 @@ def data(self): @property def itemsize(self): - """ Return the size of the dtype of the item of the underlying data """ + """ + Return the size of the dtype of the item of the underlying data. + """ warnings.warn("{obj}.itemsize is deprecated and will be removed " "in a future version".format(obj=type(self).__name__), FutureWarning, stacklevel=2) @@ -731,12 +739,16 @@ def itemsize(self): @property def nbytes(self): - """ Return the number of bytes in the underlying data """ + """ + Return the number of bytes in the underlying data. + """ return self._values.nbytes @property def strides(self): - """ Return the strides of the underlying data """ + """ + Return the strides of the underlying data. + """ warnings.warn("{obj}.strides is deprecated and will be removed " "in a future version".format(obj=type(self).__name__), FutureWarning, stacklevel=2) @@ -744,12 +756,16 @@ def strides(self): @property def size(self): - """ Return the number of elements in the underlying data """ + """ + Return the number of elements in the underlying data. + """ return self._values.size @property def flags(self): - """ Return the ndarray.flags for the underlying data """ + """ + Return the ndarray.flags for the underlying data + """ warnings.warn("{obj}.flags is deprecated and will be removed " "in a future version".format(obj=type(self).__name__), FutureWarning, stacklevel=2) @@ -757,8 +773,8 @@ def flags(self): @property def base(self): - """ Return the base object if the memory of the underlying data is - shared + """ + Return the base object if the memory of the underlying data is shared """ warnings.warn("{obj}.base is deprecated and will be removed " "in a future version".format(obj=type(self).__name__), @@ -818,7 +834,7 @@ def max(self): def argmax(self, axis=None): """ - Return a ndarray of the maximum argument indexer + Return a ndarray of the maximum argument indexer. See also -------- @@ -861,7 +877,7 @@ def min(self): def argmin(self, axis=None): """ - Return a ndarray of the minimum argument indexer + Return a ndarray of the minimum argument indexer. See also -------- @@ -900,7 +916,9 @@ def __iter__(self): @cache_readonly def hasnans(self): - """ Return if I have any nans; enables various perf speedups """ + """ + Return if I have any nans; enables various perf speedups. + """ return bool(isna(self).any()) def _reduce(self, op, name, axis=0, skipna=True, numeric_only=None, diff --git a/pandas/core/series.py b/pandas/core/series.py index e4261ad6e7dc2..47e0e97e4b810 100644 --- a/pandas/core/series.py +++ b/pandas/core/series.py @@ -390,22 +390,30 @@ def name(self, value): # ndarray compatibility @property def dtype(self): - """ Return the dtype object of the underlying data """ + """ + Return the dtype object of the underlying data. + """ return self._data.dtype @property def dtypes(self): - """ Return the dtype object of the underlying data """ + """ + Return the dtype object of the underlying data. + """ return self._data.dtype @property def ftype(self): - """ Return if the data is sparse|dense """ + """ + Return if the data is sparse|dense. + """ return self._data.ftype @property def ftypes(self): - """ Return if the data is sparse|dense """ + """ + Return if the data is sparse|dense. + """ return self._data.ftype @property @@ -443,7 +451,9 @@ def values(self): @property def _values(self): - """ Return the internal repr of this data """ + """ + Return the internal repr of this data. + """ return self._data.internal_values() def _formatting_values(self): @@ -453,7 +463,9 @@ def _formatting_values(self): return self._data.formatting_values() def get_values(self): - """ Same as values (but handles sparseness conversions); is a view """ + """ + Same as values (but handles sparseness conversions); is a view. + """ return self._data.get_values() @property From 2b7d378ea066ac0d1dad358ea6ce8b76d4d2c315 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Tue, 13 Nov 2018 11:12:49 -0500 Subject: [PATCH 07/13] Update pandas/core/base.py Co-Authored-By: avolkov --- pandas/core/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index 0c7bf9da8ff03..c1069d6256acb 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -764,7 +764,7 @@ def size(self): @property def flags(self): """ - Return the ndarray.flags for the underlying data + Return the ndarray.flags for the underlying data. """ warnings.warn("{obj}.flags is deprecated and will be removed " "in a future version".format(obj=type(self).__name__), From de70c45e6ab0f5f82ada69587c7ce763beeb556f Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Tue, 13 Nov 2018 11:12:54 -0500 Subject: [PATCH 08/13] Update pandas/core/base.py Co-Authored-By: avolkov --- pandas/core/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index c1069d6256acb..a98364ad1a209 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -774,7 +774,7 @@ def flags(self): @property def base(self): """ - Return the base object if the memory of the underlying data is shared + Return the base object if the memory of the underlying data is shared. """ warnings.warn("{obj}.base is deprecated and will be removed " "in a future version".format(obj=type(self).__name__), From f73f7be466490fdabaccdc2cc22f618e417b8bb7 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Tue, 13 Nov 2018 11:13:05 -0500 Subject: [PATCH 09/13] Update pandas/core/generic.py Co-Authored-By: avolkov --- pandas/core/generic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 9d98b534da37c..7f65bca1901d0 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2328,7 +2328,7 @@ def to_hdf(self, path_or_buf, key, **kwargs): def to_msgpack(self, path_or_buf=None, encoding='utf-8', **kwargs): """ - Serialize object to input file path using msgpack format + Serialize object to input file path using msgpack format. THIS IS AN EXPERIMENTAL LIBRARY and the storage format may not be stable until a future release. From b6edb0ce020a9ae34ddf952ca993bd3e84f4ad67 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Tue, 13 Nov 2018 11:13:07 -0500 Subject: [PATCH 10/13] Update pandas/core/base.py Co-Authored-By: avolkov --- pandas/core/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index a98364ad1a209..2f70e685bb598 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -675,7 +675,7 @@ def transpose(self, *args, **kwargs): return self T = property(transpose, doc="Return the transpose, which is by " - "definition self") + "definition self.") @property def _is_homogeneous_type(self): From 520419f0f8a885ae7d1d1265abd6056e824f4aee Mon Sep 17 00:00:00 2001 From: Alex Volkov Date: Fri, 16 Nov 2018 13:08:23 -0500 Subject: [PATCH 11/13] Updating docstring of Index.hasnans to match Series.hasnans. Fixes test_hasnans_unchached_for_series --- pandas/core/indexes/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index ff2562a4480bc..345d968796079 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -2243,7 +2243,9 @@ def _nan_idxs(self): @cache_readonly def hasnans(self): - """ return if I have any nans; enables various perf speedups """ + """ + Return if I have any nans; enables various perf speedups. + """ if self._can_hold_na: return bool(self._isnan.any()) else: From 577bf80bd05b88ecdcaa8b1cf0397dba3bfad313 Mon Sep 17 00:00:00 2001 From: Alex Volkov Date: Tue, 20 Nov 2018 11:34:50 -0500 Subject: [PATCH 12/13] Fixed too long line error. --- pandas/core/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index daaaddcf7ae64..80195a4cd4cc7 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -702,7 +702,8 @@ def shape(self): @property def ndim(self): """ - Return the number of dimensions of the underlying data, by definition 1. + Return the number of dimensions of the underlying data, + by definition 1. """ return 1 From 41a7ef5c3ffa75cad26e8f3da4d66b9b9c71b683 Mon Sep 17 00:00:00 2001 From: Alex Volkov Date: Tue, 20 Nov 2018 11:55:43 -0500 Subject: [PATCH 13/13] rewrite docstring as a single line. --- pandas/core/base.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/base.py b/pandas/core/base.py index 80195a4cd4cc7..9dc4237bdcd2d 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -702,8 +702,7 @@ def shape(self): @property def ndim(self): """ - Return the number of dimensions of the underlying data, - by definition 1. + Number of dimensions of the underlying data, by definition 1. """ return 1