Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pandas-stubs/_testing/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def assert_almost_equal(
atol: float = 1e-8,
**kwargs: Any,
) -> None: ...
def assert_dict_equal(left: dict, right: dict, compare_keys: bool = True) -> None: ...
def assert_index_equal(
left: Index,
right: Index,
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Level: TypeAlias = Hashable
Shape: TypeAlias = tuple[int, ...]
Suffixes: TypeAlias = tuple[str | None, str | None] | list[str | None]
Ordered: TypeAlias = bool | None
JSONSerializable: TypeAlias = PythonScalar | list[Any] | dict
JSONSerializable: TypeAlias = PythonScalar | list[Any] | dict[str, Any]
Frequency: TypeAlias = str | BaseOffset
PeriodFrequency: TypeAlias = (
str
Expand Down
7 changes: 5 additions & 2 deletions pandas-stubs/core/computation/eval.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from collections.abc import Mapping
from collections.abc import (
Mapping,
MutableSequence,
)
from typing import (
Any,
Literal,
Expand All @@ -21,7 +24,7 @@ def eval(
engine: Literal["python", "numexpr"] | None = ...,
local_dict: dict[str, Any] | None = None,
global_dict: dict[str, Any] | None = None,
resolvers: list[Mapping] | None = ...,
resolvers: MutableSequence[Mapping[Any, Any]] | None = ...,
level: int = 0,
target: object | None = None,
inplace: bool = False,
Expand Down
26 changes: 15 additions & 11 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ from collections.abc import (
Iterator,
Mapping,
MutableMapping,
MutableSequence,
Sequence,
)
import datetime as dt
Expand Down Expand Up @@ -502,7 +503,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
self,
orient: Literal["index"],
*,
into: defaultdict,
into: defaultdict[Any, Any],
index: Literal[True] = True,
) -> defaultdict[Hashable, dict[Hashable, Any]]: ...
@overload
Expand Down Expand Up @@ -550,7 +551,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
self,
orient: Literal["split", "tight"],
*,
into: MutableMapping | type[MutableMapping],
into: MutableMapping[Any, Any] | type[MutableMapping],
index: bool = ...,
) -> MutableMapping[str, list[Any]]: ...
@overload
Expand Down Expand Up @@ -907,7 +908,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
engine: Literal["python", "numexpr"] | None = ...,
local_dict: dict[_str, Any] | None = ...,
global_dict: dict[_str, Any] | None = ...,
resolvers: list[Mapping] | None = ...,
resolvers: MutableSequence[Mapping[Any, Any]] | None = ...,
level: int = ...,
target: object | None = ...,
inplace: Literal[True],
Expand All @@ -922,7 +923,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
engine: Literal["python", "numexpr"] | None = ...,
local_dict: dict[_str, Any] | None = ...,
global_dict: dict[_str, Any] | None = ...,
resolvers: list[Mapping] | None = ...,
resolvers: MutableSequence[Mapping[Any, Any]] | None = ...,
level: int = ...,
target: object | None = ...,
) -> Self: ...
Expand Down Expand Up @@ -1022,7 +1023,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
@overload
def fillna(
self,
value: Scalar | NAType | dict | Series | DataFrame | None = ...,
value: Scalar | NAType | dict[Any, Any] | Series | DataFrame | None = ...,
*,
axis: Axis | None = ...,
limit: int = ...,
Expand All @@ -1032,7 +1033,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
@overload
def fillna(
self,
value: Scalar | NAType | dict | Series | DataFrame | None = ...,
value: Scalar | NAType | dict[Any, Any] | Series | DataFrame | None = ...,
*,
axis: Axis | None = ...,
limit: int = ...,
Expand Down Expand Up @@ -1715,7 +1716,10 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
validate: MergeValidate | None = None,
) -> Self: ...
def round(
self, decimals: int | dict | Series = ..., *args: Any, **kwargs: Any
self,
decimals: int | dict[Any, Any] | Series = ...,
*args: Any,
**kwargs: Any,
) -> Self: ...
def corr(
self,
Expand Down Expand Up @@ -2665,7 +2669,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
compression: CompressionOptions = ...,
index: _bool | None = ...,
indent: int | None = ...,
storage_options: dict | None = ...,
storage_options: dict[Any, Any] | None = ...,
mode: Literal["a"],
) -> None: ...
@overload
Expand All @@ -2683,7 +2687,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
compression: CompressionOptions = ...,
index: _bool | None = ...,
indent: int | None = ...,
storage_options: dict | None = ...,
storage_options: dict[Any, Any] | None = ...,
mode: Literal["a"],
) -> _str: ...
@overload
Expand All @@ -2701,7 +2705,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
compression: CompressionOptions = ...,
index: _bool | None = ...,
indent: int | None = ...,
storage_options: dict | None = ...,
storage_options: dict[Any, Any] | None = ...,
mode: Literal["w"] = ...,
) -> _str: ...
@overload
Expand All @@ -2719,7 +2723,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
compression: CompressionOptions = ...,
index: _bool | None = ...,
indent: int | None = ...,
storage_options: dict | None = ...,
storage_options: dict[Any, Any] | None = ...,
mode: Literal["w"] = ...,
) -> None: ...
@overload
Expand Down
2 changes: 1 addition & 1 deletion pandas-stubs/core/groupby/generic.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ _TT = TypeVar("_TT", bound=Literal[True, False])
class DFCallable1(Protocol[P]): # ty: ignore[invalid-argument-type]
def __call__(
self, df: DataFrame, /, *args: P.args, **kwargs: P.kwargs
) -> Scalar | list[Any] | dict: ...
) -> Scalar | list[Any] | dict[Hashable, Any]: ...

class DFCallable2(Protocol[P]): # ty: ignore[invalid-argument-type]
def __call__(
Expand Down
44 changes: 33 additions & 11 deletions pandas-stubs/core/reshape/pivot.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ from pandas._typing import (
_PivotAggCallable: TypeAlias = Callable[[Series], ScalarT]

_PivotAggFunc: TypeAlias = (
_PivotAggCallable
_PivotAggCallable[ScalarT]
| np.ufunc
| Literal["mean", "sum", "count", "min", "max", "median", "std", "var"]
)
Expand Down Expand Up @@ -67,11 +67,17 @@ _Values: TypeAlias = SequenceNotStr[Any] | _ExtendedAnyArrayLike
@overload
def pivot_table(
data: DataFrame,
values: _PivotTableValuesTypes = None,
index: _PivotTableIndexTypes = None,
columns: _PivotTableColumnsTypes = None,
values: _PivotTableValuesTypes[
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we open an issue for that one on ty ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, astral-sh/ty#1846

Hashable # ty: ignore[invalid-type-arguments]
] = None,
index: _PivotTableIndexTypes[Hashable] = None, # ty: ignore[invalid-type-arguments]
columns: _PivotTableColumnsTypes[
Hashable # ty: ignore[invalid-type-arguments]
] = None,
aggfunc: (
_PivotAggFunc | Sequence[_PivotAggFunc] | Mapping[Hashable, _PivotAggFunc]
_PivotAggFunc[Scalar]
| Sequence[_PivotAggFunc[Scalar]]
| Mapping[Any, _PivotAggFunc[Scalar]]
) = "mean",
fill_value: Scalar | None = None,
margins: bool = False,
Expand All @@ -85,12 +91,20 @@ def pivot_table(
@overload
def pivot_table(
data: DataFrame,
values: _PivotTableValuesTypes = None,
values: _PivotTableValuesTypes[
Hashable # ty: ignore[invalid-type-arguments]
] = None,
*,
index: Grouper,
columns: _PivotTableColumnsTypes | np_ndarray | Index[Any] = None,
columns: (
_PivotTableColumnsTypes[Hashable] # ty: ignore[invalid-type-arguments]
| np_ndarray
| Index[Any]
) = None,
aggfunc: (
_PivotAggFunc | Sequence[_PivotAggFunc] | Mapping[Hashable, _PivotAggFunc]
_PivotAggFunc[Scalar]
| Sequence[_PivotAggFunc[Scalar]]
| Mapping[Any, _PivotAggFunc[Scalar]]
) = "mean",
fill_value: Scalar | None = None,
margins: bool = False,
Expand All @@ -102,12 +116,20 @@ def pivot_table(
@overload
def pivot_table(
data: DataFrame,
values: _PivotTableValuesTypes = None,
index: _PivotTableIndexTypes | np_ndarray | Index[Any] = None,
values: _PivotTableValuesTypes[
Hashable # ty: ignore[invalid-type-arguments]
] = None,
index: (
_PivotTableIndexTypes[Hashable] # ty: ignore[invalid-type-arguments]
| np_ndarray
| Index[Any]
) = None,
*,
columns: Grouper,
aggfunc: (
_PivotAggFunc | Sequence[_PivotAggFunc] | Mapping[Hashable, _PivotAggFunc]
_PivotAggFunc[Scalar]
| Sequence[_PivotAggFunc[Scalar]]
| Mapping[Any, _PivotAggFunc[Scalar]]
) = "mean",
fill_value: Scalar | None = None,
margins: bool = False,
Expand Down
20 changes: 13 additions & 7 deletions pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
def to_dict(self, *, into: type[dict] = ...) -> dict[Any, S1]: ...
@overload
def to_dict(
self, *, into: type[MutableMapping] | MutableMapping
self, *, into: type[MutableMapping] | MutableMapping[Any, Any]
) -> MutableMapping[Hashable, S1]: ...
def to_frame(self, name: object | None = ...) -> DataFrame: ...
@overload
Expand Down Expand Up @@ -1104,7 +1104,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
def unstack(
self,
level: IndexLabel = -1,
fill_value: int | _str | dict | None = None,
fill_value: int | _str | dict[Any, Any] | None = None,
sort: _bool = True,
) -> DataFrame: ...
@overload
Expand Down Expand Up @@ -1170,7 +1170,13 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
def apply(
self,
func: Callable[
..., Scalar | Sequence[Any] | AbstractSet[Any] | Mapping | NAType | None
...,
Scalar
| Sequence[Any]
| AbstractSet[Any]
| Mapping[Any, Any]
| NAType
| None,
],
convertDType: _bool = ...,
args: tuple[Any, ...] = ...,
Expand Down Expand Up @@ -1258,7 +1264,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
@overload
def fillna(
self,
value: Scalar | NAType | dict | Series[S1] | DataFrame | None = ...,
value: Scalar | NAType | dict[Any, Any] | Series[S1] | DataFrame | None = ...,
*,
axis: AxisIndex = ...,
limit: int | None = ...,
Expand All @@ -1267,7 +1273,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
@overload
def fillna(
self,
value: Scalar | NAType | dict | Series[S1] | DataFrame | None = ...,
value: Scalar | NAType | dict[Any, Any] | Series[S1] | DataFrame | None = ...,
*,
axis: AxisIndex = ...,
limit: int | None = ...,
Expand Down Expand Up @@ -4637,7 +4643,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
def rename_axis(
self,
*,
index: Scalar | ListLike | Callable[..., Any] | dict | None = ...,
index: Scalar | ListLike | Callable[..., Any] | dict[Any, Any] | None = ...,
copy: _bool = ...,
inplace: Literal[True],
) -> None: ...
Expand All @@ -4646,7 +4652,7 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
def rename_axis(
self,
*,
index: Scalar | ListLike | Callable[..., Any] | dict | None = ...,
index: Scalar | ListLike | Callable[..., Any] | dict[Any, Any] | None = ...,
copy: _bool = ...,
inplace: Literal[False] = False,
) -> Self: ...
Expand Down
10 changes: 1 addition & 9 deletions pandas-stubs/core/tools/timedeltas.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from collections.abc import Sequence
from datetime import timedelta
from typing import overload

Expand Down Expand Up @@ -28,14 +27,7 @@ def to_timedelta(
) -> Series[Timedelta]: ...
@overload
def to_timedelta(
arg: (
SequenceNotStr
| Sequence[float | timedelta]
| tuple[str | float | timedelta, ...]
| range
| ArrayLike
| Index
),
arg: SequenceNotStr[str | float | timedelta] | range | ArrayLike | Index,
unit: TimeDeltaUnitChoices | None = ...,
errors: RaiseCoerce = ...,
) -> TimedeltaIndex: ...
6 changes: 3 additions & 3 deletions pandas-stubs/io/clipboards.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def read_clipboard(
names: ListLikeHashable | None = ...,
index_col: int | str | Sequence[str | int] | Literal[False] | None = ...,
usecols: UsecolsArgType = ...,
dtype: DtypeArg | defaultdict | None = ...,
dtype: DtypeArg | defaultdict[Any, Any] | None = ...,
engine: CSVEngine | None = ...,
converters: dict[int | str, Callable[[str], Any]] = ...,
true_values: list[str] = ...,
Expand Down Expand Up @@ -95,7 +95,7 @@ def read_clipboard(
names: ListLikeHashable | None = ...,
index_col: int | str | Sequence[str | int] | Literal[False] | None = ...,
usecols: UsecolsArgType = ...,
dtype: DtypeArg | defaultdict | None = ...,
dtype: DtypeArg | defaultdict[Any, Any] | None = ...,
engine: CSVEngine | None = ...,
converters: dict[int | str, Callable[[str], Any]] = ...,
true_values: list[str] = ...,
Expand Down Expand Up @@ -154,7 +154,7 @@ def read_clipboard(
names: ListLikeHashable | None = ...,
index_col: int | str | Sequence[str | int] | Literal[False] | None = ...,
usecols: UsecolsArgType = ...,
dtype: DtypeArg | defaultdict | None = ...,
dtype: DtypeArg | defaultdict[Any, Any] | None = ...,
engine: CSVEngine | None = ...,
converters: dict[int | str, Callable[[str], Any]] = ...,
true_values: list[str] = ...,
Expand Down
4 changes: 3 additions & 1 deletion pandas-stubs/io/json/_normalize.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from typing import Any

from pandas import DataFrame

from pandas._typing import IgnoreRaise

def json_normalize(
data: dict | list[dict],
data: dict[str, Any] | list[dict[str, Any]],
record_path: str | list[str] | None = None,
meta: str | list[str | list[str]] | None = None,
meta_prefix: str | None = None,
Expand Down
Loading