|
10 | 10 | import numpy as np
|
11 | 11 |
|
12 | 12 | from pandas._libs import Timestamp, algos, hashtable as htable, iNaT, lib
|
13 |
| -from pandas._typing import AnyArrayLike, ArrayLike, DtypeObj |
| 13 | +from pandas._typing import AnyArrayLike, ArrayLike, DtypeObj, FrameOrSeriesUnion |
14 | 14 | from pandas.util._decorators import doc
|
15 | 15 |
|
16 | 16 | from pandas.core.dtypes.cast import (
|
|
58 | 58 | from pandas.core.indexers import validate_indices
|
59 | 59 |
|
60 | 60 | if TYPE_CHECKING:
|
61 |
| - from pandas import Series |
| 61 | + from pandas import DataFrame, Series |
62 | 62 |
|
63 | 63 | _shared_docs: Dict[str, str] = {}
|
64 | 64 |
|
@@ -462,7 +462,7 @@ def isin(comps: AnyArrayLike, values: AnyArrayLike) -> np.ndarray:
|
462 | 462 |
|
463 | 463 |
|
464 | 464 | def _factorize_array(
|
465 |
| - values, na_sentinel: int = -1, size_hint=None, na_value=None, mask=None, |
| 465 | + values, na_sentinel: int = -1, size_hint=None, na_value=None, mask=None |
466 | 466 | ) -> Tuple[np.ndarray, np.ndarray]:
|
467 | 467 | """
|
468 | 468 | Factorize an array-like to codes and uniques.
|
@@ -1101,6 +1101,9 @@ def __init__(self, obj, n: int, keep: str):
|
1101 | 1101 | if self.keep not in ("first", "last", "all"):
|
1102 | 1102 | raise ValueError('keep must be either "first", "last" or "all"')
|
1103 | 1103 |
|
| 1104 | + def compute(self, method: str) -> FrameOrSeriesUnion: |
| 1105 | + raise NotImplementedError |
| 1106 | + |
1104 | 1107 | def nlargest(self):
|
1105 | 1108 | return self.compute("nlargest")
|
1106 | 1109 |
|
@@ -1133,7 +1136,7 @@ class SelectNSeries(SelectN):
|
1133 | 1136 | nordered : Series
|
1134 | 1137 | """
|
1135 | 1138 |
|
1136 |
| - def compute(self, method): |
| 1139 | + def compute(self, method: str) -> "Series": |
1137 | 1140 |
|
1138 | 1141 | n = self.n
|
1139 | 1142 | dtype = self.obj.dtype
|
@@ -1207,7 +1210,7 @@ def __init__(self, obj, n: int, keep: str, columns):
|
1207 | 1210 | columns = list(columns)
|
1208 | 1211 | self.columns = columns
|
1209 | 1212 |
|
1210 |
| - def compute(self, method): |
| 1213 | + def compute(self, method: str) -> "DataFrame": |
1211 | 1214 |
|
1212 | 1215 | from pandas import Int64Index
|
1213 | 1216 |
|
|
0 commit comments