Skip to content

Commit 4070c2d

Browse files
committed
Merge branch 'main' of github.com:pandas-dev/pandas-stubs into feature/reduce-ndarray
2 parents ed1250e + 8a52340 commit 4070c2d

File tree

10 files changed

+429
-382
lines changed

10 files changed

+429
-382
lines changed
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
from pandas.core.interchange.dataframe_protocol import DataFrame as DataFrame
21
from pandas.core.interchange.from_dataframe import from_dataframe as from_dataframe

pandas-stubs/core/frame.pyi

Lines changed: 91 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ from pandas.core.indexing import (
5555
_IndexSliceTuple,
5656
_LocIndexer,
5757
)
58-
from pandas.core.interchange.dataframe_protocol import DataFrame as DataFrameXchg
5958
from pandas.core.reshape.pivot import (
59+
_PivotAggFunc,
6060
_PivotTableColumnsTypes,
6161
_PivotTableIndexTypes,
6262
_PivotTableValuesTypes,
@@ -126,6 +126,7 @@ from pandas._typing import (
126126
Level,
127127
ListLike,
128128
ListLikeExceptSeriesAndStr,
129+
ListLikeHashable,
129130
ListLikeU,
130131
MaskType,
131132
MergeHow,
@@ -168,6 +169,7 @@ from pandas._typing import (
168169

169170
from pandas.io.formats.style import Styler
170171
from pandas.plotting import PlotAccessor
172+
from pandas.plotting._core import _BoxPlotT
171173

172174
_T_MUTABLE_MAPPING_co = TypeVar(
173175
"_T_MUTABLE_MAPPING_co", bound=MutableMapping, covariant=True
@@ -382,24 +384,21 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
382384
| dict[Any, Any]
383385
| Iterable[ListLikeU | tuple[Hashable, ListLikeU] | dict[Any, Any]]
384386
| None
385-
) = ...,
386-
index: Axes | None = ...,
387-
columns: Axes | None = ...,
388-
dtype=...,
389-
copy: _bool = ...,
387+
) = None,
388+
index: Axes | None = None,
389+
columns: Axes | None = None,
390+
dtype: Dtype | None = None,
391+
copy: _bool | None = None,
390392
) -> Self: ...
391393
@overload
392394
def __new__(
393395
cls,
394396
data: Scalar,
395397
index: Axes,
396398
columns: Axes,
397-
dtype=...,
398-
copy: _bool = ...,
399+
dtype: Dtype | None = None,
400+
copy: _bool | None = None,
399401
) -> Self: ...
400-
def __dataframe__(
401-
self, nan_as_null: bool = ..., allow_copy: bool = ...
402-
) -> DataFrameXchg: ...
403402
def __arrow_c_stream__(self, requested_schema: object | None = None) -> object: ...
404403
@property
405404
def axes(self) -> list[Index]: ...
@@ -1365,10 +1364,12 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
13651364
) -> Self: ...
13661365
def pivot_table(
13671366
self,
1368-
values: _PivotTableValuesTypes = ...,
1369-
index: _PivotTableIndexTypes = ...,
1370-
columns: _PivotTableColumnsTypes = ...,
1371-
aggfunc="mean",
1367+
values: _PivotTableValuesTypes = None,
1368+
index: _PivotTableIndexTypes = None,
1369+
columns: _PivotTableColumnsTypes = None,
1370+
aggfunc: (
1371+
_PivotAggFunc | Sequence[_PivotAggFunc] | Mapping[Hashable, _PivotAggFunc]
1372+
) = "mean",
13721373
fill_value: Scalar | None = None,
13731374
margins: _bool = False,
13741375
dropna: _bool = True,
@@ -1700,8 +1701,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
17001701
def plot(self) -> PlotAccessor: ...
17011702
def hist(
17021703
self,
1703-
column: _str | list[_str] | None = None,
17041704
by: _str | ListLike | None = None,
1705+
bins: int | list = 10,
1706+
*,
17051707
grid: _bool = True,
17061708
xlabelsize: float | str | None = None,
17071709
xrot: float | None = None,
@@ -1712,24 +1714,88 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
17121714
sharey: _bool = False,
17131715
figsize: tuple[float, float] | None = None,
17141716
layout: tuple[int, int] | None = None,
1715-
bins: int | list = 10,
17161717
backend: _str | None = None,
1718+
legend: bool = False,
17171719
**kwargs: Any,
1718-
): ...
1720+
) -> npt.NDArray[np.object_]: ...
1721+
1722+
# Keep in sync with `pd.plotting.boxplot`
1723+
@overload
17191724
def boxplot(
17201725
self,
1721-
column: _str | list[_str] | None = None,
1722-
by: _str | ListLike | None = None,
1726+
by: None = None,
17231727
ax: PlotAxes | None = None,
17241728
fontsize: float | _str | None = None,
17251729
rot: float = 0,
17261730
grid: _bool = True,
17271731
figsize: tuple[float, float] | None = None,
17281732
layout: tuple[int, int] | None = None,
1729-
return_type: Literal["axes", "dict", "both"] | None = None,
1733+
*,
1734+
return_type: Literal["axes"] | None = None,
17301735
backend: _str | None = None,
17311736
**kwargs: Any,
1732-
): ...
1737+
) -> PlotAxes: ...
1738+
@overload
1739+
def boxplot(
1740+
self,
1741+
by: None = None,
1742+
ax: PlotAxes | None = None,
1743+
fontsize: float | _str | None = None,
1744+
rot: float = 0,
1745+
grid: _bool = True,
1746+
figsize: tuple[float, float] | None = None,
1747+
layout: tuple[int, int] | None = None,
1748+
*,
1749+
return_type: Literal["dict"],
1750+
backend: _str | None = None,
1751+
**kwargs: Any,
1752+
) -> dict[str, PlotAxes]: ...
1753+
@overload
1754+
def boxplot(
1755+
self,
1756+
by: None = None,
1757+
ax: PlotAxes | None = None,
1758+
fontsize: float | _str | None = None,
1759+
rot: float = 0,
1760+
grid: _bool = True,
1761+
figsize: tuple[float, float] | None = None,
1762+
layout: tuple[int, int] | None = None,
1763+
*,
1764+
return_type: Literal["both"],
1765+
backend: _str | None = None,
1766+
**kwargs: Any,
1767+
) -> _BoxPlotT: ...
1768+
@overload
1769+
def boxplot(
1770+
self,
1771+
by: Hashable | ListLikeHashable,
1772+
ax: PlotAxes | None = None,
1773+
fontsize: float | _str | None = None,
1774+
rot: float = 0,
1775+
grid: _bool = True,
1776+
figsize: tuple[float, float] | None = None,
1777+
layout: tuple[int, int] | None = None,
1778+
*,
1779+
return_type: None = None,
1780+
backend: _str | None = None,
1781+
**kwargs: Any,
1782+
) -> PlotAxes: ...
1783+
@overload
1784+
def boxplot(
1785+
self,
1786+
by: Hashable | ListLikeHashable,
1787+
ax: PlotAxes | None = None,
1788+
fontsize: float | _str | None = None,
1789+
rot: float = 0,
1790+
grid: _bool = True,
1791+
figsize: tuple[float, float] | None = None,
1792+
layout: tuple[int, int] | None = None,
1793+
*,
1794+
return_type: Literal["axes", "dict", "both"],
1795+
backend: _str | None = None,
1796+
**kwargs: Any,
1797+
) -> Series: ...
1798+
17331799
sparse = ...
17341800

17351801
# The rest of these are remnants from the
@@ -1852,7 +1918,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
18521918
@final
18531919
def asfreq(
18541920
self,
1855-
freq,
1921+
freq: Frequency,
18561922
method: FillnaOptions | None = None,
18571923
how: Literal["start", "end"] | None = ...,
18581924
normalize: _bool = False,
@@ -2063,8 +2129,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
20632129
axis: Axis | None = None,
20642130
) -> Self: ...
20652131
@final
2066-
def first(self, offset) -> Self: ...
2067-
@final
20682132
def first_valid_index(self) -> Scalar: ...
20692133
def floordiv(
20702134
self,
@@ -2127,8 +2191,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
21272191
**kwargs: Any,
21282192
) -> Series: ...
21292193
@final
2130-
def last(self, offset) -> Self: ...
2131-
@final
21322194
def last_valid_index(self) -> Scalar: ...
21332195
def le(self, other, axis: Axis = "columns", level: Level | None = ...) -> Self: ...
21342196
def lt(self, other, axis: Axis = "columns", level: Level | None = ...) -> Self: ...
@@ -2585,7 +2647,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
25852647
| Callable[[DataFrame], DataFrame]
25862648
| Callable[[Any], _bool]
25872649
),
2588-
other=...,
2650+
other: Scalar | Self | Callable[..., Scalar | Self] = ...,
25892651
*,
25902652
inplace: Literal[True],
25912653
axis: Axis | None = ...,
@@ -2601,7 +2663,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
26012663
| Callable[[DataFrame], DataFrame]
26022664
| Callable[[Any], _bool]
26032665
),
2604-
other=...,
2666+
other: Scalar | Self | Callable[..., Scalar | Self] = ...,
26052667
*,
26062668
inplace: Literal[False] = False,
26072669
axis: Axis | None = ...,

pandas-stubs/core/interchange/dataframe_protocol.pyi

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)