Skip to content

Commit 4367945

Browse files
committed
value_counts, crosstab
1 parent daa96bb commit 4367945

File tree

5 files changed

+14
-25
lines changed

5 files changed

+14
-25
lines changed

pandas-stubs/__init__.pyi

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,11 @@ from pandas.core.api import (
6565
to_timedelta as to_timedelta,
6666
unique as unique,
6767
)
68-
from pandas.core.api import (
69-
value_counts as value_counts, # pyright: ignore[reportUnknownVariableType]
70-
)
7168
from pandas.core.arrays.sparse import SparseDtype as SparseDtype
7269
from pandas.core.computation.api import eval as eval
7370
from pandas.core.reshape.api import (
7471
concat as concat,
72+
crosstab as crosstab,
7573
from_dummies as from_dummies,
7674
get_dummies as get_dummies,
7775
lreshape as lreshape,
@@ -83,9 +81,6 @@ from pandas.core.reshape.api import (
8381
qcut as qcut,
8482
wide_to_long as wide_to_long,
8583
)
86-
from pandas.core.reshape.api import (
87-
crosstab as crosstab, # pyright: ignore[reportUnknownVariableType]
88-
)
8984
from pandas.core.reshape.api import (
9085
cut as cut, # pyright: ignore[reportUnknownVariableType]
9186
)

pandas-stubs/core/algorithms.pyi

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ from pandas.core.series import Series
1919

2020
from pandas._typing import (
2121
T_EXTENSION_ARRAY,
22-
AnyArrayLike,
2322
GenericT,
2423
IntervalT,
2524
TakeIndexer,
@@ -88,14 +87,6 @@ def factorize(
8887
use_na_sentinel: bool = ...,
8988
size_hint: int | None = ...,
9089
) -> tuple[np_1darray_int64, Categorical]: ...
91-
def value_counts(
92-
values: AnyArrayLike | list | tuple,
93-
sort: bool = True,
94-
ascending: bool = False,
95-
normalize: bool = False,
96-
bins: int | None = None,
97-
dropna: bool = True,
98-
) -> Series: ...
9990
def take(
10091
arr: np_ndarray[Any] | ExtensionArray | Index | Series,
10192
indices: TakeIndexer,

pandas-stubs/core/api.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ from pandas.core.algorithms import (
44
factorize as factorize,
55
unique as unique,
66
)
7-
from pandas.core.algorithms import (
8-
value_counts as value_counts, # pyright: ignore[reportUnknownVariableType]
9-
)
107
from pandas.core.arrays import Categorical as Categorical
118
from pandas.core.arrays.arrow.dtype import ArrowDtype as ArrowDtype
129
from pandas.core.arrays.boolean import BooleanDtype as BooleanDtype

pandas-stubs/core/reshape/pivot.pyi

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ from pandas._typing import (
2828
Label,
2929
Scalar,
3030
ScalarT,
31+
SequenceNotStr,
3132
np_ndarray,
3233
)
3334

@@ -121,11 +122,14 @@ def pivot(
121122
columns: _NonIterableHashable | Sequence[HashableT2] = ...,
122123
values: _NonIterableHashable | Sequence[HashableT3] = ...,
123124
) -> DataFrame: ...
125+
126+
_Values: TypeAlias = SequenceNotStr[Any] | _ExtendedAnyArrayLike
127+
124128
@overload
125129
def crosstab(
126-
index: list | _ExtendedAnyArrayLike | list[Sequence | _ExtendedAnyArrayLike],
127-
columns: list | _ExtendedAnyArrayLike | list[Sequence | _ExtendedAnyArrayLike],
128-
values: list | _ExtendedAnyArrayLike,
130+
index: _Values | list[_Values],
131+
columns: _Values | list[_Values],
132+
values: _Values,
129133
rownames: list[HashableT1] | None = ...,
130134
colnames: list[HashableT2] | None = ...,
131135
*,
@@ -137,8 +141,8 @@ def crosstab(
137141
) -> DataFrame: ...
138142
@overload
139143
def crosstab(
140-
index: list | _ExtendedAnyArrayLike | list[Sequence | _ExtendedAnyArrayLike],
141-
columns: list | _ExtendedAnyArrayLike | list[Sequence | _ExtendedAnyArrayLike],
144+
index: _Values | list[_Values],
145+
columns: _Values | list[_Values],
142146
values: None = None,
143147
rownames: list[HashableT1] | None = ...,
144148
colnames: list[HashableT2] | None = ...,

tests/extension/decimal/array.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,12 @@ def convert_values(param: Any) -> ExtensionArray | list[Any]:
345345

346346
def value_counts(self, dropna: bool = True) -> Series:
347347
from pandas.core.algorithms import (
348-
value_counts, # pyright: ignore[reportUnknownVariableType]
348+
value_counts, # pyright: ignore[reportAttributeAccessIssue,reportUnknownVariableType]
349349
)
350350

351-
return value_counts(self.to_numpy(), dropna=dropna)
351+
return value_counts(
352+
self.to_numpy(), dropna=dropna
353+
) # pyright: ignore[reportUnknownVariableType]
352354

353355

354356
DecimalArray._add_arithmetic_ops()

0 commit comments

Comments
 (0)