@@ -27,6 +27,7 @@ from matplotlib.axes import (
27
27
import numpy as np
28
28
from pandas import (
29
29
Period ,
30
+ PeriodDtype ,
30
31
Timedelta ,
31
32
Timestamp ,
32
33
)
@@ -104,6 +105,7 @@ from pandas._typing import (
104
105
CategoryDtypeArg ,
105
106
ComplexDtypeArg ,
106
107
CompressionOptions ,
108
+ Dtype ,
107
109
DtypeBackend ,
108
110
DtypeObj ,
109
111
FilePath ,
@@ -209,92 +211,55 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
209
211
_ListLike : TypeAlias = ArrayLike | dict [_str , np .ndarray ] | list | tuple | Index
210
212
__hash__ : ClassVar [None ]
211
213
214
+ # TODO: can __new__ be converted to __init__? Pandas implements __init__
212
215
@overload
213
216
def __new__ (
214
217
cls ,
215
218
data : DatetimeIndex | Sequence [Timestamp | np .datetime64 | datetime ],
216
219
index : Axes | None = ...,
217
- dtype = ...,
220
+ dtype : TimestampDtypeArg = ...,
218
221
name : Hashable | None = ...,
219
222
copy : bool = ...,
220
- fastpath : bool = ...,
221
223
) -> TimestampSeries : ...
222
224
@overload
223
225
def __new__ (
224
226
cls ,
225
227
data : _ListLike ,
226
- dtype : Literal ["datetime64[ns]" ],
227
228
index : Axes | None = ...,
229
+ * ,
230
+ dtype : TimestampDtypeArg ,
228
231
name : Hashable | None = ...,
229
232
copy : bool = ...,
230
- fastpath : bool = ...,
231
233
) -> TimestampSeries : ...
232
234
@overload
233
235
def __new__ (
234
236
cls ,
235
237
data : PeriodIndex ,
236
238
index : Axes | None = ...,
237
- dtype = ...,
239
+ dtype : PeriodDtype = ...,
238
240
name : Hashable | None = ...,
239
241
copy : bool = ...,
240
- fastpath : bool = ...,
241
242
) -> PeriodSeries : ...
242
243
@overload
243
244
def __new__ (
244
245
cls ,
245
246
data : TimedeltaIndex | Sequence [Timedelta | np .timedelta64 | timedelta ],
246
247
index : Axes | None = ...,
247
- dtype = ...,
248
+ dtype : TimedeltaDtypeArg = ...,
248
249
name : Hashable | None = ...,
249
250
copy : bool = ...,
250
- fastpath : bool = ...,
251
251
) -> TimedeltaSeries : ...
252
252
@overload
253
253
def __new__ (
254
254
cls ,
255
- data : IntervalIndex [Interval [int ]] | Interval [int ] | Sequence [Interval [int ]],
256
- index : Axes | None = ...,
257
- dtype = ...,
258
- name : Hashable | None = ...,
259
- copy : bool = ...,
260
- fastpath : bool = ...,
261
- ) -> IntervalSeries [int ]: ...
262
- @overload
263
- def __new__ (
264
- cls ,
265
- data : IntervalIndex [Interval [float ]]
266
- | Interval [float ]
267
- | Sequence [Interval [float ]],
268
- index : Axes | None = ...,
269
- dtype = ...,
270
- name : Hashable | None = ...,
271
- copy : bool = ...,
272
- fastpath : bool = ...,
273
- ) -> IntervalSeries [float ]: ...
274
- @overload
275
- def __new__ (
276
- cls ,
277
- data : IntervalIndex [Interval [Timestamp ]]
278
- | Interval [Timestamp ]
279
- | Sequence [Interval [Timestamp ]],
280
- index : Axes | None = ...,
281
- dtype = ...,
282
- name : Hashable | None = ...,
283
- copy : bool = ...,
284
- fastpath : bool = ...,
285
- ) -> IntervalSeries [Timestamp ]: ...
286
- @overload
287
- def __new__ (
288
- cls ,
289
- data : IntervalIndex [Interval [Timedelta ]]
290
- | Interval [Timedelta ]
291
- | Sequence [Interval [Timedelta ]],
255
+ data : IntervalIndex [Interval [_OrderableT ]]
256
+ | Interval [_OrderableT ]
257
+ | Sequence [Interval [_OrderableT ]],
292
258
index : Axes | None = ...,
293
- dtype = ...,
259
+ dtype : Literal [ "Interval" ] = ...,
294
260
name : Hashable | None = ...,
295
261
copy : bool = ...,
296
- fastpath : bool = ...,
297
- ) -> IntervalSeries [Timedelta ]: ...
262
+ ) -> IntervalSeries [_OrderableT ]: ...
298
263
@overload
299
264
def __new__ (
300
265
cls ,
@@ -303,27 +268,24 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
303
268
index : Axes | None = ...,
304
269
name : Hashable | None = ...,
305
270
copy : bool = ...,
306
- fastpath : bool = ...,
307
271
) -> Self : ...
308
272
@overload
309
273
def __new__ (
310
274
cls ,
311
275
data : Series [S1 ] | dict [int , S1 ] | dict [_str , S1 ] = ...,
312
276
index : Axes | None = ...,
313
- dtype = ...,
277
+ dtype : Dtype = ...,
314
278
name : Hashable | None = ...,
315
279
copy : bool = ...,
316
- fastpath : bool = ...,
317
280
) -> Self : ...
318
281
@overload
319
282
def __new__ (
320
283
cls ,
321
284
data : object | _ListLike | None = ...,
322
285
index : Axes | None = ...,
323
- dtype = ...,
286
+ dtype : Dtype = ...,
324
287
name : Hashable | None = ...,
325
288
copy : bool = ...,
326
- fastpath : bool = ...,
327
289
) -> Series : ...
328
290
@property
329
291
def hasnans (self ) -> bool : ...
0 commit comments