Skip to content

Commit 4059076

Browse files
PR Feedback
1 parent f18f651 commit 4059076

File tree

6 files changed

+195
-142
lines changed

6 files changed

+195
-142
lines changed

pandas-stubs/core/frame.pyi

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ from pandas.core.indexes.multi import MultiIndex
4545
from pandas.core.indexes.period import PeriodIndex
4646
from pandas.core.indexes.timedeltas import TimedeltaIndex
4747
from pandas.core.indexing import (
48+
_AtIndexer,
49+
_iAtIndexer,
4850
_iLocIndexer,
4951
_IndexSliceTuple,
5052
_LocIndexer,
@@ -285,6 +287,77 @@ class _LocIndexerFrame(_LocIndexer, Generic[_T]):
285287
value: Scalar | NAType | NaTType | ArrayLike | Series | list | dict | None,
286288
) -> None: ...
287289

290+
class _iAtIndexerFrame(_iAtIndexer, Generic[_T]):
291+
@overload
292+
def __getitem__(self, idx: tuple[int, int]) -> Scalar: ...
293+
@overload
294+
def __getitem__(self, idx: IndexingInt) -> Series: ...
295+
@overload
296+
def __getitem__(self, idx: tuple[IndexType | MaskType, int]) -> Series: ...
297+
@overload
298+
def __getitem__(self, idx: tuple[int, IndexType | MaskType]) -> Series: ...
299+
@overload
300+
def __getitem__(
301+
self,
302+
idx: (
303+
IndexType
304+
| MaskType
305+
| tuple[IndexType | MaskType, IndexType | MaskType]
306+
| tuple[slice]
307+
),
308+
) -> _T: ...
309+
def __setitem__(
310+
self,
311+
idx: (
312+
int
313+
| IndexType
314+
| tuple[int, int]
315+
| tuple[IndexType, int]
316+
| tuple[IndexType, IndexType]
317+
| tuple[int, IndexType]
318+
),
319+
value: (
320+
Scalar
321+
| Series
322+
| DataFrame
323+
| np.ndarray
324+
| NAType
325+
| NaTType
326+
| Mapping[Hashable, Scalar | NAType | NaTType]
327+
| None
328+
),
329+
) -> None: ...
330+
331+
class _AtIndexerFrame(_AtIndexer, Generic[_T]):
332+
def __getitem__(
333+
self,
334+
idx: tuple[
335+
int
336+
| StrLike
337+
| Timestamp
338+
| tuple[Scalar, ...]
339+
| Callable[[DataFrame], ScalarT],
340+
int | StrLike | tuple[Scalar, ...],
341+
],
342+
) -> Scalar: ...
343+
def __setitem__(
344+
self,
345+
idx: (
346+
MaskType | StrLike | _IndexSliceTuple | list[ScalarT] | IndexingInt | slice
347+
),
348+
value: (
349+
Scalar
350+
| NAType
351+
| NaTType
352+
| ArrayLike
353+
| Series
354+
| DataFrame
355+
| list
356+
| Mapping[Hashable, Scalar | NAType | NaTType]
357+
| None
358+
),
359+
) -> None: ...
360+
288361
# With mypy 1.14.1 and python 3.12, the second overload needs a type-ignore statement
289362
if sys.version_info >= (3, 12):
290363
class _GetItemHack:
@@ -1591,13 +1664,13 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
15911664
axis: Axis = 0,
15921665
skipna: _bool = True,
15931666
numeric_only: _bool = False,
1594-
) -> Series: ...
1667+
) -> Series[int]: ...
15951668
def idxmin(
15961669
self,
15971670
axis: Axis = 0,
15981671
skipna: _bool = True,
15991672
numeric_only: _bool = False,
1600-
) -> Series: ...
1673+
) -> Series[int]: ...
16011674
def mode(
16021675
self,
16031676
axis: Axis = 0,
@@ -1683,7 +1756,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
16831756
def __iter__(self) -> Iterator[Hashable]: ...
16841757
# properties
16851758
@property
1686-
def at(self): ... # Not sure what to do with this yet; look at source
1759+
def at(
1760+
self,
1761+
) -> _AtIndexerFrame: ... # Not sure what to do with this yet; look at source
16871762
@property
16881763
def columns(self) -> Index[str]: ...
16891764
@columns.setter # setter needs to be right next to getter; otherwise mypy complains
@@ -1695,7 +1770,9 @@ class DataFrame(NDFrame, OpsMixin, _GetItemHack):
16951770
@property
16961771
def empty(self) -> _bool: ...
16971772
@property
1698-
def iat(self): ... # Not sure what to do with this yet; look at source
1773+
def iat(
1774+
self,
1775+
) -> _iAtIndexerFrame: ... # Not sure what to do with this yet; look at source
16991776
@property
17001777
def iloc(self) -> _iLocIndexerFrame[Self]: ...
17011778
@property

pandas-stubs/core/indexes/datetimes.pyi

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ from pandas import (
2323
from pandas.core.indexes.accessors import DatetimeIndexProperties
2424
from pandas.core.indexes.datetimelike import DatetimeTimedeltaMixin
2525
from pandas.core.series import (
26-
Series,
2726
TimedeltaSeries,
2827
TimestampSeries,
2928
)
@@ -45,22 +44,9 @@ from pandas.core.dtypes.dtypes import DatetimeTZDtype
4544
from pandas.tseries.offsets import BaseOffset
4645

4746
class DatetimeIndex(DatetimeTimedeltaMixin[Timestamp], DatetimeIndexProperties):
48-
def __init__(
49-
self,
50-
data: AxesData,
51-
freq: Frequency = ...,
52-
tz: TimeZones = ...,
53-
ambiguous: str = ...,
54-
dayfirst: bool = ...,
55-
yearfirst: bool = ...,
56-
dtype: Dtype = ...,
57-
copy: bool = ...,
58-
name: Hashable = ...,
59-
) -> None: ...
60-
@classmethod
6147
def __new__(
6248
cls,
63-
data: AxesData | Series,
49+
data: AxesData,
6450
freq: Frequency = ...,
6551
tz: TimeZones = ...,
6652
ambiguous: str = ...,

0 commit comments

Comments
 (0)