Skip to content
Open
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
338 changes: 205 additions & 133 deletions pandas-stubs/_typing.pyi

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion pandas-stubs/core/arrays/floating.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
from pandas.core.arrays.numeric import NumericDtype
from pandas.core.arrays.numeric import (
NumericArray,
NumericDtype,
)

class Float32Dtype(NumericDtype): ...
class Float64Dtype(NumericDtype): ...
class FloatingArray(NumericArray): ...
8 changes: 8 additions & 0 deletions pandas-stubs/core/arrays/numeric.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
from pandas.core.arrays.masked import BaseMaskedArray

from pandas._libs.properties import cache_readonly

from pandas.core.dtypes.dtypes import BaseMaskedDtype

class NumericDtype(BaseMaskedDtype): ...

class NumericArray(BaseMaskedArray):
@cache_readonly
def dtype(self) -> NumericDtype: ...
29 changes: 21 additions & 8 deletions pandas-stubs/core/construction.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,43 @@ from typing import overload
import numpy as np
from pandas.core.arrays.base import ExtensionArray
from pandas.core.arrays.boolean import BooleanArray
from pandas.core.arrays.floating import FloatingArray
from pandas.core.arrays.integer import IntegerArray

from pandas._libs.missing import NAType
from pandas._typing import (
BooleanDtypeArg,
IntDtypeArg,
UIntDtypeArg,
PandasBooleanDtypeArg,
PandasFloatDtypeArg,
PandasIntDtypeArg,
PandasUIntDtypeArg,
np_ndarray_anyint,
np_ndarray_bool,
np_ndarray_float,
)

from pandas.core.dtypes.dtypes import ExtensionDtype

@overload
def array( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
data: Sequence[bool | NAType | None],
dtype: BooleanDtypeArg | None = None,
data: Sequence[bool | np.bool | NAType | None] | np_ndarray_bool | BooleanArray,
dtype: PandasBooleanDtypeArg | None = None,
copy: bool = True,
) -> BooleanArray: ...
@overload
def array(
data: Sequence[int | NAType | None],
dtype: IntDtypeArg | UIntDtypeArg | None = None,
def array( # type: ignore[overload-overlap]
data: Sequence[int | np.integer | NAType | None] | np_ndarray_anyint | IntegerArray,
dtype: PandasIntDtypeArg | PandasUIntDtypeArg | None = None,
copy: bool = True,
) -> IntegerArray: ...
@overload
def array(
data: (
Sequence[float | np.floating | NAType | None] | np_ndarray_float | FloatingArray
),
dtype: PandasFloatDtypeArg | None = None,
copy: bool = True,
) -> FloatingArray: ...
@overload
def array(
data: Sequence[object],
dtype: str | np.dtype | ExtensionDtype | None = None,
Expand Down
29 changes: 24 additions & 5 deletions pandas-stubs/core/indexes/base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ from typing import (
ClassVar,
Generic,
Literal,
TypeAlias,
final,
overload,
type_check_only,
Expand All @@ -30,6 +31,7 @@ from _typeshed import (
)
import numpy as np
from pandas.core.arrays.boolean import BooleanArray
from pandas.core.arrays.floating import FloatingArray
from pandas.core.base import (
ArrayIndexTimedeltaNoSeq,
ElementOpsMixin,
Expand Down Expand Up @@ -82,6 +84,7 @@ from pandas._typing import (
AnyArrayLikeInt,
ArrayLike,
AxesData,
BuiltinFloatDtypeArg,
CategoryDtypeArg,
DropKeep,
Dtype,
Expand All @@ -98,6 +101,10 @@ from pandas._typing import (
Level,
MaskType,
NaPosition,
NumpyFloatNot16DtypeArg,
PandasAstypeFloatDtypeArg,
PandasFloatDtypeArg,
PyArrowFloatDtypeArg,
ReindexMethod,
S2_contra,
Scalar,
Expand All @@ -122,6 +129,13 @@ from pandas._typing import (

from pandas.core.dtypes.dtypes import PeriodDtype

FloatNotNumpy16DtypeArg: TypeAlias = (
BuiltinFloatDtypeArg
| PandasFloatDtypeArg
| NumpyFloatNot16DtypeArg
| PyArrowFloatDtypeArg
)

class InvalidIndexError(Exception): ...

class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
Expand Down Expand Up @@ -160,9 +174,8 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
@overload
def __new__(
cls,
data: Sequence[float | np.floating] | IndexOpsMixin[float] | np_ndarray_float,
*,
dtype: Literal["float"] | type_t[float | np.floating] = ...,
data: Sequence[float | np.floating] | np_ndarray_float | FloatingArray,
dtype: None = None,
copy: bool = ...,
name: Hashable = ...,
tupleize_cols: bool = ...,
Expand All @@ -171,8 +184,7 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
def __new__(
cls,
data: AxesData,
*,
dtype: Literal["float"] | type_t[float | np.floating],
dtype: FloatNotNumpy16DtypeArg,
copy: bool = ...,
name: Hashable = ...,
tupleize_cols: bool = ...,
Expand Down Expand Up @@ -361,6 +373,13 @@ class Index(IndexOpsMixin[S1], ElementOpsMixin[S1]):
@final
def ravel(self, order: _str = ...): ...
def view(self, cls=...): ...
@overload
def astype(
self,
dtype: FloatNotNumpy16DtypeArg | PandasAstypeFloatDtypeArg,
copy: bool = True,
) -> Index[float]: ...
@overload
def astype(self, dtype: DtypeArg, copy: bool = True) -> Index: ...
def take(
self,
Expand Down
Loading