@@ -211,46 +211,57 @@ class _LocIndexerSeries(_LocIndexer, Generic[S1]):
211
211
value : S1 | ArrayLike | Series [S1 ] | None ,
212
212
) -> None : ...
213
213
214
+ _ListLike : TypeAlias = (
215
+ ArrayLike | dict [_str , np .ndarray ] | Sequence [S1 ] | IndexOpsMixin [S1 ]
216
+ )
217
+
214
218
class Series (IndexOpsMixin [S1 ], NDFrame ):
215
- _ListLike : TypeAlias = ArrayLike | dict [_str , np .ndarray ] | list | tuple | Index
216
219
__hash__ : ClassVar [None ]
217
220
218
- # TODO: can __new__ be converted to __init__? Pandas implements __init__
219
221
@overload
220
- def __new__ (
222
+ def __new__ ( # type: ignore[misc]
221
223
cls ,
222
- data : DatetimeIndex | Sequence [Timestamp | np .datetime64 | datetime ],
224
+ data : DatetimeIndex
225
+ | Sequence [np .datetime64 | datetime ]
226
+ | np .datetime64
227
+ | datetime ,
223
228
index : Axes | None = ...,
229
+ * ,
224
230
dtype : TimestampDtypeArg = ...,
225
- name : Hashable | None = ...,
231
+ name : Hashable = ...,
226
232
copy : bool = ...,
227
233
) -> TimestampSeries : ...
228
234
@overload
229
- def __new__ (
235
+ def __new__ ( # type: ignore[misc]
230
236
cls ,
231
237
data : _ListLike ,
232
238
index : Axes | None = ...,
233
239
* ,
234
240
dtype : TimestampDtypeArg ,
235
- name : Hashable | None = ...,
241
+ name : Hashable = ...,
236
242
copy : bool = ...,
237
243
) -> TimestampSeries : ...
238
244
@overload
239
- def __new__ (
245
+ def __new__ ( # type: ignore[misc]
240
246
cls ,
241
247
data : PeriodIndex ,
242
248
index : Axes | None = ...,
249
+ * ,
243
250
dtype : PeriodDtype = ...,
244
- name : Hashable | None = ...,
251
+ name : Hashable = ...,
245
252
copy : bool = ...,
246
253
) -> PeriodSeries : ...
247
254
@overload
248
- def __new__ (
255
+ def __new__ ( # type: ignore[misc]
249
256
cls ,
250
- data : TimedeltaIndex | Sequence [Timedelta | np .timedelta64 | timedelta ],
257
+ data : TimedeltaIndex
258
+ | Sequence [np .timedelta64 | timedelta ]
259
+ | np .timedelta64
260
+ | timedelta ,
251
261
index : Axes | None = ...,
262
+ * ,
252
263
dtype : TimedeltaDtypeArg = ...,
253
- name : Hashable | None = ...,
264
+ name : Hashable = ...,
254
265
copy : bool = ...,
255
266
) -> TimedeltaSeries : ...
256
267
@overload
@@ -260,35 +271,39 @@ class Series(IndexOpsMixin[S1], NDFrame):
260
271
| Interval [_OrderableT ]
261
272
| Sequence [Interval [_OrderableT ]],
262
273
index : Axes | None = ...,
274
+ * ,
263
275
dtype : Literal ["Interval" ] = ...,
264
- name : Hashable | None = ...,
276
+ name : Hashable = ...,
265
277
copy : bool = ...,
266
278
) -> IntervalSeries [_OrderableT ]: ...
267
279
@overload
268
280
def __new__ (
269
281
cls ,
270
- data : object | _ListLike | Series [S1 ] | dict [int , S1 ] | dict [_str , S1 ] | None ,
271
- dtype : type [S1 ],
282
+ data : Scalar | _ListLike | dict [int , Any ] | dict [_str , Any ] | None ,
272
283
index : Axes | None = ...,
273
- name : Hashable | None = ...,
284
+ * ,
285
+ dtype : type [S1 ],
286
+ name : Hashable = ...,
274
287
copy : bool = ...,
275
288
) -> Self : ...
276
289
@overload
277
290
def __new__ (
278
291
cls ,
279
- data : Series [S1 ] | dict [int , S1 ] | dict [_str , S1 ] = ... ,
292
+ data : S1 | _ListLike [S1 ] | dict [int , S1 ] | dict [_str , S1 ],
280
293
index : Axes | None = ...,
294
+ * ,
281
295
dtype : Dtype = ...,
282
- name : Hashable | None = ...,
296
+ name : Hashable = ...,
283
297
copy : bool = ...,
284
298
) -> Self : ...
285
299
@overload
286
300
def __new__ (
287
301
cls ,
288
- data : object | _ListLike | None = ...,
302
+ data : Scalar | _ListLike | dict [ int , Any ] | dict [ _str , Any ] | None = ...,
289
303
index : Axes | None = ...,
304
+ * ,
290
305
dtype : Dtype = ...,
291
- name : Hashable | None = ...,
306
+ name : Hashable = ...,
292
307
copy : bool = ...,
293
308
) -> Series : ...
294
309
@property
@@ -342,8 +357,8 @@ class Series(IndexOpsMixin[S1], NDFrame):
342
357
| Series [S1 ]
343
358
| slice
344
359
| MaskType
345
- | tuple [S1 | slice , ...],
346
- ) -> Series : ...
360
+ | tuple [Hashable | slice , ...],
361
+ ) -> Self : ...
347
362
@overload
348
363
def __getitem__ (self , idx : int | _str ) -> S1 : ...
349
364
def __setitem__ (self , key , value ) -> None : ...
@@ -680,11 +695,13 @@ class Series(IndexOpsMixin[S1], NDFrame):
680
695
@overload
681
696
def dot (self , other : DataFrame ) -> Series [S1 ]: ...
682
697
@overload
683
- def dot (self , other : _ListLike ) -> np .ndarray : ...
698
+ def dot (
699
+ self , other : ArrayLike | dict [_str , np .ndarray ] | Sequence [S1 ] | Index [S1 ]
700
+ ) -> np .ndarray : ...
684
701
def __matmul__ (self , other ): ...
685
702
def __rmatmul__ (self , other ): ...
686
703
@overload
687
- def searchsorted (
704
+ def searchsorted ( # type: ignore[misc]
688
705
self ,
689
706
value : _ListLike ,
690
707
side : Literal ["left" , "right" ] = ...,
@@ -781,7 +798,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
781
798
ignore_index : _bool = ...,
782
799
inplace : Literal [False ] = ...,
783
800
key : Callable | None = ...,
784
- ) -> Series : ...
801
+ ) -> Self : ...
785
802
@overload
786
803
def sort_index (
787
804
self ,
@@ -820,6 +837,14 @@ class Series(IndexOpsMixin[S1], NDFrame):
820
837
) -> DataFrame : ...
821
838
def map (self , arg , na_action : Literal ["ignore" ] | None = ...) -> Series [S1 ]: ...
822
839
@overload
840
+ def aggregate ( # type: ignore[misc]
841
+ self : Series [int ],
842
+ func : Literal ["mean" ],
843
+ axis : AxisIndex = ...,
844
+ * args ,
845
+ ** kwargs ,
846
+ ) -> float : ...
847
+ @overload
823
848
def aggregate (
824
849
self ,
825
850
func : AggFuncTypeBase ,
@@ -834,7 +859,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
834
859
axis : AxisIndex = ...,
835
860
* args ,
836
861
** kwargs ,
837
- ) -> Series [ S1 ] : ...
862
+ ) -> Series : ...
838
863
agg = aggregate
839
864
@overload
840
865
def transform (
@@ -902,7 +927,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
902
927
inplace : Literal [False ] = ...,
903
928
level : Level | None = ...,
904
929
errors : IgnoreRaise = ...,
905
- ) -> Series : ...
930
+ ) -> Self : ...
906
931
@overload
907
932
def rename (
908
933
self ,
@@ -913,7 +938,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
913
938
inplace : Literal [False ] = ...,
914
939
level : Level | None = ...,
915
940
errors : IgnoreRaise = ...,
916
- ) -> Series : ...
941
+ ) -> Self : ...
917
942
@overload
918
943
def rename (
919
944
self ,
@@ -932,7 +957,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
932
957
copy : _bool = ...,
933
958
limit : int | None = ...,
934
959
tolerance : float | None = ...,
935
- ) -> Series : ...
960
+ ) -> Self : ...
936
961
@overload
937
962
def drop (
938
963
self ,
@@ -956,7 +981,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
956
981
level : Level | None = ...,
957
982
inplace : Literal [False ] = ...,
958
983
errors : IgnoreRaise = ...,
959
- ) -> Series : ...
984
+ ) -> Self : ...
960
985
@overload
961
986
def drop (
962
987
self ,
@@ -1344,7 +1369,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
1344
1369
na_option : Literal ["keep" , "top" , "bottom" ] = ...,
1345
1370
ascending : _bool = ...,
1346
1371
pct : _bool = ...,
1347
- ) -> Series : ...
1372
+ ) -> Series [ float ] : ...
1348
1373
def where (
1349
1374
self ,
1350
1375
cond : Series [S1 ]
@@ -1431,14 +1456,10 @@ class Series(IndexOpsMixin[S1], NDFrame):
1431
1456
# just failed to generate these so I couldn't match
1432
1457
# them up.
1433
1458
@overload
1434
- def __add__ (self , other : TimestampSeries ) -> TimestampSeries : ...
1435
- @overload
1436
- def __add__ (self , other : DatetimeIndex ) -> TimestampSeries : ...
1437
- @overload
1438
- def __add__ (self , other : Timestamp ) -> TimestampSeries : ...
1459
+ def __add__ (self , other : S1 | Self ) -> Self : ...
1439
1460
@overload
1440
1461
def __add__ (
1441
- self , other : num | _str | Timedelta | _ListLike | Series [ S1 ] | np .timedelta64
1462
+ self , other : num | _str | Timedelta | _ListLike | Series | np .timedelta64
1442
1463
) -> Series : ...
1443
1464
# ignore needed for mypy as we want different results based on the arguments
1444
1465
@overload # type: ignore[override]
@@ -1479,7 +1500,10 @@ class Series(IndexOpsMixin[S1], NDFrame):
1479
1500
) -> Series [bool ]: ...
1480
1501
@overload
1481
1502
def __or__ (self , other : int | np_ndarray_anyint | Series [int ]) -> Series [int ]: ...
1482
- def __radd__ (self , other : num | _str | _ListLike | Series [S1 ]) -> Series [S1 ]: ...
1503
+ @overload
1504
+ def __radd__ (self , other : S1 | Series [S1 ]) -> Self : ...
1505
+ @overload
1506
+ def __radd__ (self , other : num | _str | _ListLike | Series ) -> Series : ...
1483
1507
# ignore needed for mypy as we want different results based on the arguments
1484
1508
@overload # type: ignore[override]
1485
1509
def __rand__ ( # type: ignore[misc]
@@ -1961,11 +1985,16 @@ class Series(IndexOpsMixin[S1], NDFrame):
1961
1985
axis : AxisIndex | None = ...,
1962
1986
copy : _bool = ...,
1963
1987
inplace : Literal [False ] = ...,
1964
- ) -> Series : ...
1965
- def set_axis (
1966
- self , labels , * , axis : Axis = ..., copy : _bool = ...
1967
- ) -> Series [S1 ]: ...
1988
+ ) -> Self : ...
1989
+ def set_axis (self , labels , * , axis : Axis = ..., copy : _bool = ...) -> Self : ...
1968
1990
def __iter__ (self ) -> Iterator [S1 ]: ...
1991
+ def xs (
1992
+ self ,
1993
+ key : Hashable ,
1994
+ axis : AxisIndex = ...,
1995
+ level : Level | None = ...,
1996
+ drop_level : _bool = ...,
1997
+ ) -> Self : ...
1969
1998
1970
1999
class TimestampSeries (Series [Timestamp ]):
1971
2000
# ignore needed because of mypy
@@ -2092,13 +2121,6 @@ class TimedeltaSeries(Series[Timedelta]):
2092
2121
numeric_only : _bool = ...,
2093
2122
** kwargs ,
2094
2123
) -> Timedelta : ...
2095
- def xs (
2096
- self ,
2097
- key : Hashable ,
2098
- axis : AxisIndex = ...,
2099
- level : Level | None = ...,
2100
- drop_level : _bool = ...,
2101
- ) -> Series : ...
2102
2124
2103
2125
class PeriodSeries (Series [Period ]):
2104
2126
# ignore needed because of mypy
0 commit comments