diff --git a/pandas-stubs/api/interchange/__init__.pyi b/pandas-stubs/api/interchange/__init__.pyi index 147ebac46..19592c366 100644 --- a/pandas-stubs/api/interchange/__init__.pyi +++ b/pandas-stubs/api/interchange/__init__.pyi @@ -1,2 +1 @@ -from pandas.core.interchange.dataframe_protocol import DataFrame as DataFrame from pandas.core.interchange.from_dataframe import from_dataframe as from_dataframe diff --git a/pandas-stubs/core/frame.pyi b/pandas-stubs/core/frame.pyi index 93af6f79d..a3d6f70ab 100644 --- a/pandas-stubs/core/frame.pyi +++ b/pandas-stubs/core/frame.pyi @@ -54,7 +54,6 @@ from pandas.core.indexing import ( _IndexSliceTuple, _LocIndexer, ) -from pandas.core.interchange.dataframe_protocol import DataFrame as DataFrameXchg from pandas.core.reshape.pivot import ( _PivotTableColumnsTypes, _PivotTableIndexTypes, @@ -382,11 +381,11 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | dict[Any, Any] | Iterable[ListLikeU | tuple[Hashable, ListLikeU] | dict[Any, Any]] | None - ) = ..., - index: Axes | None = ..., - columns: Axes | None = ..., - dtype=..., - copy: _bool = ..., + ) = None, + index: Axes | None = None, + columns: Axes | None = None, + dtype: Dtype | None = None, + copy: _bool | None = None, ) -> Self: ... @overload def __new__( @@ -394,12 +393,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): data: Scalar, index: Axes, columns: Axes, - dtype=..., - copy: _bool = ..., + dtype: Dtype | None = None, + copy: _bool | None = None, ) -> Self: ... - def __dataframe__( - self, nan_as_null: bool = ..., allow_copy: bool = ... - ) -> DataFrameXchg: ... def __arrow_c_stream__(self, requested_schema: object | None = None) -> object: ... @property def axes(self) -> list[Index]: ... @@ -1852,7 +1848,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): @final def asfreq( self, - freq, + freq: Frequency, method: FillnaOptions | None = None, how: Literal["start", "end"] | None = ..., normalize: _bool = False, @@ -2069,8 +2065,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): axis: Axis | None = None, ) -> Self: ... @final - def first(self, offset) -> Self: ... - @final def first_valid_index(self) -> Scalar: ... def floordiv( self, @@ -2133,8 +2127,6 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): **kwargs: Any, ) -> Series: ... @final - def last(self, offset) -> Self: ... - @final def last_valid_index(self) -> Scalar: ... def le(self, other, axis: Axis = "columns", level: Level | None = ...) -> Self: ... def lt(self, other, axis: Axis = "columns", level: Level | None = ...) -> Self: ... @@ -2605,7 +2597,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | Callable[[DataFrame], DataFrame] | Callable[[Any], _bool] ), - other=..., + other: Scalar | Self | Callable[..., Scalar | Self] = ..., *, inplace: Literal[True], axis: Axis | None = ..., @@ -2621,7 +2613,7 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack): | Callable[[DataFrame], DataFrame] | Callable[[Any], _bool] ), - other=..., + other: Scalar | Self | Callable[..., Scalar | Self] = ..., *, inplace: Literal[False] = False, axis: Axis | None = ..., diff --git a/pandas-stubs/core/interchange/dataframe_protocol.pyi b/pandas-stubs/core/interchange/dataframe_protocol.pyi deleted file mode 100644 index 94595ea1f..000000000 --- a/pandas-stubs/core/interchange/dataframe_protocol.pyi +++ /dev/null @@ -1,124 +0,0 @@ -import abc -from abc import ( - ABC, - abstractmethod, -) -from collections.abc import ( - Iterable, - Sequence, -) -import enum -from typing import ( - Any, - TypedDict, - cast, -) - -from typing_extensions import Self - -class DlpackDeviceType(enum.IntEnum): - CPU = cast(int, ...) - CUDA = cast(int, ...) - CPU_PINNED = cast(int, ...) - OPENCL = cast(int, ...) - VULKAN = cast(int, ...) - METAL = cast(int, ...) - VPI = cast(int, ...) - ROCM = cast(int, ...) - -class DtypeKind(enum.IntEnum): - INT = cast(int, ...) - UINT = cast(int, ...) - FLOAT = cast(int, ...) - BOOL = cast(int, ...) - STRING = cast(int, ...) - DATETIME = cast(int, ...) - CATEGORICAL = cast(int, ...) - -class ColumnNullType(enum.IntEnum): - NON_NULLABLE = cast(int, ...) - USE_NAN = cast(int, ...) - USE_SENTINEL = cast(int, ...) - USE_BITMASK = cast(int, ...) - USE_BYTEMASK = cast(int, ...) - -class ColumnBuffers(TypedDict): - data: tuple[Buffer, Any] - validity: tuple[Buffer, Any] | None - offsets: tuple[Buffer, Any] | None - -class CategoricalDescription(TypedDict): - is_ordered: bool - is_dictionary: bool - categories: Column | None - -class Buffer(ABC, metaclass=abc.ABCMeta): - @property - @abstractmethod - def bufsize(self) -> int: ... - @property - @abstractmethod - def ptr(self) -> int: ... - @abstractmethod - def __dlpack__(self) -> Any: ... - @abstractmethod - def __dlpack_device__(self) -> tuple[DlpackDeviceType, int | None]: ... - -class Column(ABC, metaclass=abc.ABCMeta): - @property - @abstractmethod - def size(self) -> int: ... - @property - @abstractmethod - def offset(self) -> int: ... - @property - @abstractmethod - def dtype(self) -> tuple[DtypeKind, int, str, str]: ... - @property - @abstractmethod - def describe_categorical(self) -> CategoricalDescription: ... - @property - @abstractmethod - def describe_null(self) -> tuple[ColumnNullType, Any]: ... - @property - @abstractmethod - def null_count(self) -> int | None: ... - @property - @abstractmethod - def metadata(self) -> dict[str, Any]: ... - @abstractmethod - def num_chunks(self) -> int: ... - @abstractmethod - def get_chunks(self, n_chunks: int | None = ...) -> Iterable[Column]: ... - @abstractmethod - def get_buffers(self) -> ColumnBuffers: ... - -class DataFrame(ABC, metaclass=abc.ABCMeta): - version: int - @abstractmethod - def __dataframe__( - self, nan_as_null: bool = ..., allow_copy: bool = ... - ) -> Self: ... - @property - @abstractmethod - def metadata(self) -> dict[str, Any]: ... - @abstractmethod - def num_columns(self) -> int: ... - @abstractmethod - def num_rows(self) -> int | None: ... - @abstractmethod - def num_chunks(self) -> int: ... - @abstractmethod - def column_names(self) -> Iterable[str]: ... - @abstractmethod - def get_column(self, i: int) -> Column: ... - @abstractmethod - def get_column_by_name(self, name: str) -> Column: ... - @abstractmethod - def get_columns(self) -> Iterable[Column]: ... - @abstractmethod - def select_columns(self, indices: Sequence[int]) -> DataFrame: ... - @abstractmethod - def select_columns_by_name(self, names: Sequence[str]) -> DataFrame: ... - @abstractmethod - def get_chunks(self, n_chunks: int | None = ...) -> Iterable[DataFrame]: ...