forked from pandas-dev/pandas-stubs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalgorithms.pyi
71 lines (67 loc) · 2 KB
/
algorithms.pyi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
from collections.abc import Sequence
from typing import overload
import numpy as np
from pandas import (
Categorical,
CategoricalIndex,
Index,
IntervalIndex,
PeriodIndex,
Series,
)
from pandas.api.extensions import ExtensionArray
from pandas._typing import (
AnyArrayLike,
IntervalT,
)
# These are type: ignored because the Index types overlap due to inheritance but indices
# with extension types return the same type while standard type return ndarray
@overload
def unique(values: PeriodIndex) -> PeriodIndex: ... # type: ignore[misc] # pyright: ignore[reportOverlappingOverload]
@overload
def unique(values: CategoricalIndex) -> CategoricalIndex: ... # type: ignore[misc]
@overload
def unique(values: IntervalIndex[IntervalT]) -> IntervalIndex[IntervalT]: ... # type: ignore[misc]
@overload
def unique(values: Index) -> np.ndarray: ...
@overload
def unique(values: Categorical) -> Categorical: ...
@overload
def unique(values: Series) -> np.ndarray | ExtensionArray: ...
@overload
def unique(values: np.ndarray | list) -> np.ndarray: ...
@overload
def unique(values: ExtensionArray) -> ExtensionArray: ...
@overload
def factorize(
values: Sequence,
sort: bool = ...,
use_na_sentinel: bool = ...,
size_hint: int | None = ...,
) -> tuple[np.ndarray, np.ndarray]: ...
@overload
def factorize(
values: Index | Series,
sort: bool = ...,
# Not actually positional-only, used to handle deprecations in 1.5.0
*,
use_na_sentinel: bool = ...,
size_hint: int | None = ...,
) -> tuple[np.ndarray, Index]: ...
@overload
def factorize(
values: Categorical,
sort: bool = ...,
# Not actually positional-only, used to handle deprecations in 1.5.0
*,
use_na_sentinel: bool = ...,
size_hint: int | None = ...,
) -> tuple[np.ndarray, Categorical]: ...
def value_counts(
values: AnyArrayLike | list | tuple,
sort: bool = ...,
ascending: bool = ...,
normalize: bool = ...,
bins: int | None = ...,
dropna: bool = ...,
) -> Series: ...