Skip to content

Commit 2bc8049

Browse files
authored
Type DataFrame methods: __dataframe__, first, last, asfreq, where (#1470)
* Type `DataFrame` methods: `__dataframe__`, `first`, `last`, `asfreq`, `where` * remove deprecated dataframe protocol
1 parent ca481c6 commit 2bc8049

File tree

3 files changed

+10
-143
lines changed

3 files changed

+10
-143
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: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ from pandas.core.indexing import (
5454
_IndexSliceTuple,
5555
_LocIndexer,
5656
)
57-
from pandas.core.interchange.dataframe_protocol import DataFrame as DataFrameXchg
5857
from pandas.core.reshape.pivot import (
5958
_PivotTableColumnsTypes,
6059
_PivotTableIndexTypes,
@@ -382,24 +381,21 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
382381
| dict[Any, Any]
383382
| Iterable[ListLikeU | tuple[Hashable, ListLikeU] | dict[Any, Any]]
384383
| None
385-
) = ...,
386-
index: Axes | None = ...,
387-
columns: Axes | None = ...,
388-
dtype=...,
389-
copy: _bool = ...,
384+
) = None,
385+
index: Axes | None = None,
386+
columns: Axes | None = None,
387+
dtype: Dtype | None = None,
388+
copy: _bool | None = None,
390389
) -> Self: ...
391390
@overload
392391
def __new__(
393392
cls,
394393
data: Scalar,
395394
index: Axes,
396395
columns: Axes,
397-
dtype=...,
398-
copy: _bool = ...,
396+
dtype: Dtype | None = None,
397+
copy: _bool | None = None,
399398
) -> Self: ...
400-
def __dataframe__(
401-
self, nan_as_null: bool = ..., allow_copy: bool = ...
402-
) -> DataFrameXchg: ...
403399
def __arrow_c_stream__(self, requested_schema: object | None = None) -> object: ...
404400
@property
405401
def axes(self) -> list[Index]: ...
@@ -1852,7 +1848,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
18521848
@final
18531849
def asfreq(
18541850
self,
1855-
freq,
1851+
freq: Frequency,
18561852
method: FillnaOptions | None = None,
18571853
how: Literal["start", "end"] | None = ...,
18581854
normalize: _bool = False,
@@ -2069,8 +2065,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
20692065
axis: Axis | None = None,
20702066
) -> Self: ...
20712067
@final
2072-
def first(self, offset) -> Self: ...
2073-
@final
20742068
def first_valid_index(self) -> Scalar: ...
20752069
def floordiv(
20762070
self,
@@ -2133,8 +2127,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
21332127
**kwargs: Any,
21342128
) -> Series: ...
21352129
@final
2136-
def last(self, offset) -> Self: ...
2137-
@final
21382130
def last_valid_index(self) -> Scalar: ...
21392131
def le(self, other, axis: Axis = "columns", level: Level | None = ...) -> Self: ...
21402132
def lt(self, other, axis: Axis = "columns", level: Level | None = ...) -> Self: ...
@@ -2605,7 +2597,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
26052597
| Callable[[DataFrame], DataFrame]
26062598
| Callable[[Any], _bool]
26072599
),
2608-
other=...,
2600+
other: Scalar | Self | Callable[..., Scalar | Self] = ...,
26092601
*,
26102602
inplace: Literal[True],
26112603
axis: Axis | None = ...,
@@ -2621,7 +2613,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
26212613
| Callable[[DataFrame], DataFrame]
26222614
| Callable[[Any], _bool]
26232615
),
2624-
other=...,
2616+
other: Scalar | Self | Callable[..., Scalar | Self] = ...,
26252617
*,
26262618
inplace: Literal[False] = False,
26272619
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)