diff --git a/pandas/_typing.py b/pandas/_typing.py index 445eff9e19e47..e480933e9da39 100644 --- a/pandas/_typing.py +++ b/pandas/_typing.py @@ -23,6 +23,7 @@ from pandas.core.indexes.base import Index # noqa: F401 from pandas.core.series import Series # noqa: F401 from pandas.core.generic import NDFrame # noqa: F401 + from pandas.io.formats.style import Styler # noqa: F401 AnyArrayLike = TypeVar("AnyArrayLike", "ExtensionArray", "Index", "Series", np.ndarray) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index fde3d1657b4f2..08ad92478c67c 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -84,7 +84,7 @@ ) from pandas.core.dtypes.missing import isna, notna -from pandas._typing import Axes, Dtype, FilePathOrBuffer +from pandas._typing import Axes, Dtype, FilePathOrBuffer, Styler from pandas.core import algorithms, common as com, nanops, ops from pandas.core.accessor import CachedAccessor from pandas.core.arrays import Categorical, ExtensionArray @@ -804,7 +804,7 @@ def to_string( # ---------------------------------------------------------------------- @property - def style(self): + def style(self) -> "Styler": """ Returns a Styler object. @@ -882,7 +882,7 @@ def items(self) -> Iterable[Tuple[Optional[Hashable], Series]]: def iteritems(self): yield from self.items() - def iterrows(self): + def iterrows(self) -> Iterable[Tuple[Index, Series]]: """ Iterate over DataFrame rows as (index, Series) pairs. @@ -1020,7 +1020,7 @@ def __len__(self) -> int: """ return len(self.index) - def dot(self, other): + def dot(self, other: Union[Series, DataFrame]) -> Union[Series, DataFrame]: """ Compute the matrix multiplication between the DataFrame and other. @@ -1131,13 +1131,13 @@ def dot(self, other): else: # pragma: no cover raise TypeError("unsupported type: {oth}".format(oth=type(other))) - def __matmul__(self, other): + def __matmul__(self, other: Union[Series, DataFrame]) -> Union[Series, DataFrame]: """ Matrix multiplication using binary `@` operator in Python>=3.5. """ return self.dot(other) - def __rmatmul__(self, other): + def __rmatmul__(self, other: Union[Series, DataFrame]) -> Union[Series, DataFrame]: """ Matrix multiplication using binary `@` operator in Python>=3.5. """ @@ -4631,7 +4631,7 @@ def drop_duplicates(self, subset=None, keep="first", inplace=False): duplicated = self.duplicated(subset, keep=keep) if inplace: - (inds,) = (-duplicated)._ndarray_values.nonzero() + inds = (-duplicated)._ndarray_values.nonzero()[0] new_data = self._data.take(inds) self._update_inplace(new_data) else: