diff --git a/pandas/core/arrays/sparse.py b/pandas/core/arrays/sparse.py index 672261c2a407e..24e33c32d0898 100644 --- a/pandas/core/arrays/sparse.py +++ b/pandas/core/arrays/sparse.py @@ -1861,6 +1861,10 @@ 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 diff --git a/pandas/core/base.py b/pandas/core/base.py index 17108c16c07dc..9dc4237bdcd2d 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -668,12 +668,14 @@ 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 - T = property(transpose, doc="return the transpose, which is by " - "definition self") + T = property(transpose, doc="Return the transpose, which is by " + "definition self.") @property def _is_homogeneous_type(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 + """ + 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/generic.py b/pandas/core/generic.py index 9f56433c6868e..6b991aac84ae9 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -2331,7 +2331,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/indexes/base.py b/pandas/core/indexes/base.py index 2f449b4b33d8d..f11fe5539eed2 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: diff --git a/pandas/core/indexes/datetimelike.py b/pandas/core/indexes/datetimelike.py index 7616bc4ea10ef..e08a9e4dd5508 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 ---------- diff --git a/pandas/core/series.py b/pandas/core/series.py index 8fba3030be9d4..0a0a1d6797cf9 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'} @@ -389,22 +389,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 @@ -441,7 +449,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): @@ -451,7 +461,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 @@ -3443,9 +3455,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