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
92 changes: 81 additions & 11 deletions pandas-stubs/core/frame.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ from pandas.core.indexing import (
_LocIndexer,
)
from pandas.core.reshape.pivot import (
_PivotAggFunc,
_PivotTableColumnsTypes,
_PivotTableIndexTypes,
_PivotTableValuesTypes,
Expand Down Expand Up @@ -124,6 +125,7 @@ from pandas._typing import (
Level,
ListLike,
ListLikeExceptSeriesAndStr,
ListLikeHashable,
ListLikeU,
MaskType,
MergeHow,
Expand Down Expand Up @@ -167,6 +169,7 @@ from pandas._typing import (

from pandas.io.formats.style import Styler
from pandas.plotting import PlotAccessor
from pandas.plotting._core import _BoxPlotT

_T_MUTABLE_MAPPING_co = TypeVar(
"_T_MUTABLE_MAPPING_co", bound=MutableMapping, covariant=True
Expand Down Expand Up @@ -1361,10 +1364,12 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
) -> Self: ...
def pivot_table(
self,
values: _PivotTableValuesTypes = ...,
index: _PivotTableIndexTypes = ...,
columns: _PivotTableColumnsTypes = ...,
aggfunc="mean",
values: _PivotTableValuesTypes = None,
index: _PivotTableIndexTypes = None,
columns: _PivotTableColumnsTypes = None,
aggfunc: (
_PivotAggFunc | Sequence[_PivotAggFunc] | Mapping[Hashable, _PivotAggFunc]
) = "mean",
fill_value: Scalar | None = None,
margins: _bool = False,
dropna: _bool = True,
Expand Down Expand Up @@ -1696,8 +1701,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
def plot(self) -> PlotAccessor: ...
def hist(
self,
column: _str | list[_str] | None = None,
by: _str | ListLike | None = None,
bins: int | list = 10,
*,
grid: _bool = True,
xlabelsize: float | str | None = None,
xrot: float | None = None,
Expand All @@ -1708,24 +1714,88 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
sharey: _bool = False,
figsize: tuple[float, float] | None = None,
layout: tuple[int, int] | None = None,
bins: int | list = 10,
backend: _str | None = None,
legend: bool = False,
**kwargs: Any,
): ...
) -> npt.NDArray[np.object_]: ...

# Keep in sync with `pd.plotting.boxplot`
@overload
def boxplot(
self,
column: _str | list[_str] | None = None,
by: _str | ListLike | None = None,
by: None = None,
ax: PlotAxes | None = None,
fontsize: float | _str | None = None,
rot: float = 0,
grid: _bool = True,
figsize: tuple[float, float] | None = None,
layout: tuple[int, int] | None = None,
return_type: Literal["axes", "dict", "both"] | None = None,
*,
return_type: Literal["axes"] | None = None,
backend: _str | None = None,
**kwargs: Any,
): ...
) -> PlotAxes: ...
@overload
def boxplot(
self,
by: None = None,
ax: PlotAxes | None = None,
fontsize: float | _str | None = None,
rot: float = 0,
grid: _bool = True,
figsize: tuple[float, float] | None = None,
layout: tuple[int, int] | None = None,
*,
return_type: Literal["dict"],
backend: _str | None = None,
**kwargs: Any,
) -> dict[str, PlotAxes]: ...
@overload
def boxplot(
self,
by: None = None,
ax: PlotAxes | None = None,
fontsize: float | _str | None = None,
rot: float = 0,
grid: _bool = True,
figsize: tuple[float, float] | None = None,
layout: tuple[int, int] | None = None,
*,
return_type: Literal["both"],
backend: _str | None = None,
**kwargs: Any,
) -> _BoxPlotT: ...
@overload
def boxplot(
self,
by: Hashable | ListLikeHashable,
ax: PlotAxes | None = None,
fontsize: float | _str | None = None,
rot: float = 0,
grid: _bool = True,
figsize: tuple[float, float] | None = None,
layout: tuple[int, int] | None = None,
*,
return_type: None = None,
backend: _str | None = None,
**kwargs: Any,
) -> PlotAxes: ...
@overload
def boxplot(
self,
by: Hashable | ListLikeHashable,
ax: PlotAxes | None = None,
fontsize: float | _str | None = None,
rot: float = 0,
grid: _bool = True,
figsize: tuple[float, float] | None = None,
layout: tuple[int, int] | None = None,
*,
return_type: Literal["axes", "dict", "both"],
backend: _str | None = None,
**kwargs: Any,
) -> Series: ...

sparse = ...

# The rest of these are remnants from the
Expand Down
57 changes: 29 additions & 28 deletions pandas-stubs/core/reshape/pivot.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from collections.abc import (
)
import datetime
from typing import (
Any,
Literal,
TypeAlias,
overload,
Expand Down Expand Up @@ -64,54 +65,54 @@ _ExtendedAnyArrayLike: TypeAlias = AnyArrayLike | ArrayLike
@overload
def pivot_table(
data: DataFrame,
values: _PivotTableValuesTypes = ...,
index: _PivotTableIndexTypes = ...,
columns: _PivotTableColumnsTypes = ...,
values: _PivotTableValuesTypes = None,
index: _PivotTableIndexTypes = None,
columns: _PivotTableColumnsTypes = None,
aggfunc: (
_PivotAggFunc | Sequence[_PivotAggFunc] | Mapping[Hashable, _PivotAggFunc]
) = ...,
fill_value: Scalar | None = ...,
margins: bool = ...,
dropna: bool = ...,
margins_name: str = ...,
observed: bool = ...,
sort: bool = ...,
) = "mean",
fill_value: Scalar | None = None,
margins: bool = False,
dropna: bool = True,
margins_name: Hashable = "All",
observed: bool = True,
sort: bool = True,
) -> DataFrame: ...

# Can only use Index or ndarray when index or columns is a Grouper
@overload
def pivot_table(
data: DataFrame,
values: _PivotTableValuesTypes = ...,
values: _PivotTableValuesTypes = None,
*,
index: Grouper,
columns: _PivotTableColumnsTypes | Index | npt.NDArray = ...,
columns: _PivotTableColumnsTypes | npt.NDArray[Any] | Index = None,
aggfunc: (
_PivotAggFunc | Sequence[_PivotAggFunc] | Mapping[Hashable, _PivotAggFunc]
) = ...,
fill_value: Scalar | None = ...,
margins: bool = ...,
dropna: bool = ...,
margins_name: str = ...,
observed: bool = ...,
sort: bool = ...,
) = "mean",
fill_value: Scalar | None = None,
margins: bool = False,
dropna: bool = True,
margins_name: Hashable = "All",
observed: bool = True,
sort: bool = True,
) -> DataFrame: ...
@overload
def pivot_table(
data: DataFrame,
values: _PivotTableValuesTypes = ...,
index: _PivotTableIndexTypes | Index | npt.NDArray = ...,
values: _PivotTableValuesTypes = None,
index: _PivotTableIndexTypes | npt.NDArray[Any] | Index = None,
*,
columns: Grouper,
aggfunc: (
_PivotAggFunc | Sequence[_PivotAggFunc] | Mapping[Hashable, _PivotAggFunc]
) = ...,
fill_value: Scalar | None = ...,
margins: bool = ...,
dropna: bool = ...,
margins_name: str = ...,
observed: bool = ...,
sort: bool = ...,
) = "mean",
fill_value: Scalar | None = None,
margins: bool = False,
dropna: bool = True,
margins_name: Hashable = "All",
observed: bool = True,
sort: bool = True,
) -> DataFrame: ...
def pivot(
data: DataFrame,
Expand Down
90 changes: 64 additions & 26 deletions pandas-stubs/plotting/_core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ from pandas._typing import (
HashableT1,
HashableT2,
HashableT3,
ListLikeHashable,
npt,
)

Expand All @@ -39,50 +40,87 @@ _SingleColor: TypeAlias = (
)
_PlotAccessorColor: TypeAlias = str | list[_SingleColor] | dict[HashableT, _SingleColor]

# Keep in sync with `DataFrame.boxplot`
@overload
def boxplot(
data: DataFrame,
column: Hashable | list[HashableT1] | None = ...,
by: Hashable | list[HashableT2] | None = ...,
ax: Axes | None = ...,
fontsize: float | str | None = ...,
rot: float = ...,
grid: bool = ...,
figsize: tuple[float, float] | None = ...,
layout: tuple[int, int] | None = ...,
return_type: Literal["axes"] | None = ...,
column: Hashable | ListLikeHashable,
by: None = None,
ax: Axes | None = None,
fontsize: float | str | None = None,
rot: float = 0,
grid: bool = True,
figsize: tuple[float, float] | None = None,
layout: tuple[int, int] | None = None,
*,
return_type: Literal["axes"] | None = None,
backend: str | None = None,
**kwargs: Any,
) -> Axes: ...
@overload
def boxplot(
data: DataFrame,
column: Hashable | list[HashableT1] | None = ...,
by: Hashable | list[HashableT2] | None = ...,
ax: Axes | None = ...,
fontsize: float | str | None = ...,
rot: float = ...,
grid: bool = ...,
figsize: tuple[float, float] | None = ...,
layout: tuple[int, int] | None = ...,
column: Hashable | ListLikeHashable,
by: None = None,
ax: Axes | None = None,
fontsize: float | str | None = None,
rot: float = 0,
grid: bool = True,
figsize: tuple[float, float] | None = None,
layout: tuple[int, int] | None = None,
*,
return_type: Literal["dict"],
backend: str | None = None,
**kwargs: Any,
) -> dict[str, list[Line2D]]: ...
) -> dict[str, Axes]: ...
@overload
def boxplot(
data: DataFrame,
column: Hashable | list[HashableT1] | None = ...,
by: Hashable | list[HashableT2] | None = ...,
ax: Axes | None = ...,
fontsize: float | str | None = ...,
rot: float = ...,
grid: bool = ...,
figsize: tuple[float, float] | None = ...,
layout: tuple[int, int] | None = ...,
column: Hashable | ListLikeHashable,
by: None = None,
ax: Axes | None = None,
fontsize: float | str | None = None,
rot: float = 0,
grid: bool = True,
figsize: tuple[float, float] | None = None,
layout: tuple[int, int] | None = None,
*,
return_type: Literal["both"],
backend: str | None = None,
**kwargs: Any,
) -> _BoxPlotT: ...
@overload
def boxplot(
data: DataFrame,
column: Hashable | ListLikeHashable,
by: Hashable | ListLikeHashable,
ax: Axes | None = None,
fontsize: float | str | None = None,
rot: float = 0,
grid: bool = True,
figsize: tuple[float, float] | None = None,
layout: tuple[int, int] | None = None,
*,
return_type: None = None,
backend: str | None = None,
**kwargs: Any,
) -> Axes: ...
@overload
def boxplot(
data: DataFrame,
column: Hashable | ListLikeHashable,
by: Hashable | ListLikeHashable,
ax: Axes | None = None,
fontsize: float | str | None = None,
rot: float = 0,
grid: bool = True,
figsize: tuple[float, float] | None = None,
layout: tuple[int, int] | None = None,
*,
return_type: Literal["axes", "dict", "both"],
backend: str | None = None,
**kwargs: Any,
) -> Series: ...

class PlotAccessor:
def __init__(self, data: Series | DataFrame) -> None: ...
Expand Down
Loading