diff --git a/pandas/_libs/indexing.pyx b/pandas/_libs/indexing.pyx index 308e914b7b5b7..7a25a52c7e608 100644 --- a/pandas/_libs/indexing.pyx +++ b/pandas/_libs/indexing.pyx @@ -11,7 +11,7 @@ cdef class _NDFrameIndexerBase: self._ndim = None @property - def ndim(self): + def ndim(self) -> int: # Delay `ndim` instantiation until required as reading it # from `obj` isn't entirely cheap. ndim = self._ndim diff --git a/pandas/core/base.py b/pandas/core/base.py index 10e7b5d186bba..e070005c56d7a 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -686,7 +686,7 @@ def transpose(self, *args, **kwargs): ) @property - def _is_homogeneous_type(self): + def _is_homogeneous_type(self) -> bool: """ Whether the object has a single dtype. @@ -711,7 +711,7 @@ def shape(self): return self._values.shape @property - def ndim(self): + def ndim(self) -> int: """ Number of dimensions of the underlying data, by definition 1. """ @@ -1467,7 +1467,7 @@ def is_monotonic(self): is_monotonic_increasing = is_monotonic @property - def is_monotonic_decreasing(self): + def is_monotonic_decreasing(self) -> bool: """ Return boolean if values in the object are monotonic_decreasing. diff --git a/pandas/core/computation/ops.py b/pandas/core/computation/ops.py index fe74b6994be7c..8fab5bd87d4fe 100644 --- a/pandas/core/computation/ops.py +++ b/pandas/core/computation/ops.py @@ -167,7 +167,7 @@ def name(self): return self._name @property - def ndim(self): + def ndim(self) -> int: return self._value.ndim diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 2468c43337d0d..c8ce7561a12b8 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -569,7 +569,7 @@ def axes(self): return [self._get_axis(a) for a in self._AXIS_ORDERS] @property - def ndim(self): + def ndim(self) -> int: """ Return an int representing the number of axes / array dimensions. diff --git a/pandas/core/indexes/base.py b/pandas/core/indexes/base.py index ee124ba3851b1..9748342c86f31 100644 --- a/pandas/core/indexes/base.py +++ b/pandas/core/indexes/base.py @@ -607,7 +607,7 @@ def _update_inplace(self, result, **kwargs): # guard when called from IndexOpsMixin raise TypeError("Index can't be updated inplace") - def is_(self, other): + def is_(self, other) -> bool: """ More flexible, faster check like ``is`` but that works through views. @@ -1452,7 +1452,7 @@ def rename(self, name, inplace=False): # Level-Centric Methods @property - def nlevels(self): + def nlevels(self) -> int: """ Number of levels. """ @@ -1677,7 +1677,7 @@ def is_monotonic_increasing(self): return self._engine.is_monotonic_increasing @property - def is_monotonic_decreasing(self): + def is_monotonic_decreasing(self) -> bool: """ Return if the index is monotonic decreasing (only equal or decreasing) values. @@ -1735,7 +1735,7 @@ def is_unique(self): return self._engine.is_unique @property - def has_duplicates(self): + def has_duplicates(self) -> bool: return not self.is_unique def is_boolean(self): diff --git a/pandas/core/indexes/category.py b/pandas/core/indexes/category.py index 0187b47ab50a1..49bb705e09469 100644 --- a/pandas/core/indexes/category.py +++ b/pandas/core/indexes/category.py @@ -463,7 +463,7 @@ def is_monotonic_increasing(self): return self._engine.is_monotonic_increasing @property - def is_monotonic_decreasing(self): + def is_monotonic_decreasing(self) -> bool: return self._engine.is_monotonic_decreasing @Appender(_index_shared_docs["index_unique"] % _index_doc_kwargs) diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index cf5295460d8fc..1c4addfb44839 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -558,7 +558,7 @@ def is_monotonic_increasing(self): return self._engine.is_monotonic_increasing @cache_readonly - def is_monotonic_decreasing(self): + def is_monotonic_decreasing(self) -> bool: """ Return True if the IntervalIndex is monotonic decreasing (only equal or decreasing values), else False diff --git a/pandas/core/indexes/multi.py b/pandas/core/indexes/multi.py index a6a6de6c13c04..a83fd6bf59f05 100644 --- a/pandas/core/indexes/multi.py +++ b/pandas/core/indexes/multi.py @@ -675,7 +675,7 @@ def array(self): raise ValueError(msg) @property - def _is_homogeneous_type(self): + def _is_homogeneous_type(self) -> bool: """Whether the levels of a MultiIndex all have the same dtype. This looks at the dtypes of the levels. @@ -1427,7 +1427,7 @@ def is_monotonic_increasing(self): return Index(self.values).is_monotonic @cache_readonly - def is_monotonic_decreasing(self): + def is_monotonic_decreasing(self) -> bool: """ return if the index is monotonic decreasing (only equal or decreasing) values. diff --git a/pandas/core/indexes/range.py b/pandas/core/indexes/range.py index 67791417f1bb5..962ba8cc00557 100644 --- a/pandas/core/indexes/range.py +++ b/pandas/core/indexes/range.py @@ -353,11 +353,11 @@ def is_monotonic_increasing(self): return self._range.step > 0 or len(self) <= 1 @cache_readonly - def is_monotonic_decreasing(self): + def is_monotonic_decreasing(self) -> bool: return self._range.step < 0 or len(self) <= 1 @property - def has_duplicates(self): + def has_duplicates(self) -> bool: return False def __contains__(self, key: Union[int, np.integer]) -> bool: diff --git a/pandas/core/internals/managers.py b/pandas/core/internals/managers.py index fbe1db1c23cdb..6408da37d4343 100644 --- a/pandas/core/internals/managers.py +++ b/pandas/core/internals/managers.py @@ -166,7 +166,7 @@ def shape(self): return tuple(len(ax) for ax in self.axes) @property - def ndim(self): + def ndim(self) -> int: return len(self.axes) def set_axis(self, axis, new_labels):