@@ -48,7 +48,6 @@ from matplotlib.axes import (
4848 SubplotBase ,
4949)
5050import numpy as np
51- from numpy import typing as npt
5251from pandas import (
5352 Index ,
5453 Period ,
@@ -63,12 +62,15 @@ from pandas.core.api import (
6362 Int64Dtype as Int64Dtype ,
6463)
6564from pandas .core .arrays .base import ExtensionArray
66- from pandas .core .arrays .boolean import BooleanDtype
65+ from pandas .core .arrays .boolean import (
66+ BooleanDtype ,
67+ )
6768from pandas .core .arrays .categorical import (
6869 Categorical ,
6970 CategoricalAccessor ,
7071)
7172from pandas .core .arrays .datetimes import DatetimeArray
73+ from pandas .core .arrays .floating import FloatingArray
7274from pandas .core .arrays .timedeltas import TimedeltaArray
7375from pandas .core .base import (
7476 ArrayIndexSeriesTimedeltaNoSeq ,
@@ -190,6 +192,10 @@ from pandas._typing import (
190192 NaPosition ,
191193 NsmallestNlargestKeep ,
192194 ObjectDtypeArg ,
195+ PandasAstypeComplexDtypeArg ,
196+ PandasAstypeFloatDtypeArg ,
197+ PandasAstypeTimedeltaDtypeArg ,
198+ PandasAstypeTimestampDtypeArg ,
193199 PeriodFrequency ,
194200 QuantileInterpolation ,
195201 RandomState ,
@@ -343,41 +349,32 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
343349 __index__ : ClassVar [None ]
344350 __hash__ : ClassVar [None ] # pyright: ignore[reportIncompatibleMethodOverride]
345351
346- @overload
347- def __new__ (
348- cls ,
349- data : npt .NDArray [np .float64 ],
350- index : AxesData | None = ...,
351- dtype : Dtype = ...,
352- name : Hashable = ...,
353- copy : bool = ...,
354- ) -> Series [float ]: ...
355352 @overload
356353 def __new__ (
357354 cls ,
358355 data : Sequence [Never ],
359- index : AxesData | None = ... ,
360- dtype : Dtype = ... ,
361- name : Hashable = ... ,
362- copy : bool = ... ,
356+ index : AxesData | None = None ,
357+ dtype : None = None ,
358+ name : Hashable = None ,
359+ copy : bool | None = None ,
363360 ) -> Series : ...
364361 @overload
365362 def __new__ (
366363 cls ,
367364 data : Sequence [list [_str ]],
368- index : AxesData | None = ... ,
369- dtype : Dtype = ... ,
370- name : Hashable = ... ,
371- copy : bool = ... ,
365+ index : AxesData | None = None ,
366+ dtype : None = None ,
367+ name : Hashable = None ,
368+ copy : bool | None = None ,
372369 ) -> Series [list [_str ]]: ...
373370 @overload
374371 def __new__ (
375372 cls ,
376373 data : Sequence [_str ],
377- index : AxesData | None = ... ,
378- dtype : Dtype = ... ,
379- name : Hashable = ... ,
380- copy : bool = ... ,
374+ index : AxesData | None = None ,
375+ dtype : Dtype | None = None ,
376+ name : Hashable = None ,
377+ copy : bool | None = None ,
381378 ) -> Series [_str ]: ...
382379 @overload
383380 def __new__ (
@@ -390,48 +387,48 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
390387 | datetime
391388 | date
392389 ),
393- index : AxesData | None = ... ,
390+ index : AxesData | None = None ,
394391 dtype : TimestampDtypeArg = ...,
395- name : Hashable = ... ,
396- copy : bool = ... ,
392+ name : Hashable = None ,
393+ copy : bool | None = None ,
397394 ) -> Series [Timestamp ]: ...
398395 @overload
399396 def __new__ (
400397 cls ,
401- data : _DataLike ,
402- index : AxesData | None = ... ,
398+ data : Sequence [ datetime | np . timedelta64 ] | np_ndarray_dt | DatetimeArray ,
399+ index : AxesData | None = None ,
403400 * ,
404401 dtype : TimestampDtypeArg ,
405- name : Hashable = ... ,
406- copy : bool = ... ,
402+ name : Hashable = None ,
403+ copy : bool | None = None ,
407404 ) -> Series [Timestamp ]: ...
408405 @overload
409406 def __new__ (
410407 cls ,
411408 data : _DataLike ,
412- index : AxesData | None = ... ,
409+ index : AxesData | None = None ,
413410 * ,
414411 dtype : CategoryDtypeArg ,
415- name : Hashable = ... ,
416- copy : bool = ... ,
412+ name : Hashable = None ,
413+ copy : bool | None = None ,
417414 ) -> Series [CategoricalDtype ]: ...
418415 @overload
419416 def __new__ (
420417 cls ,
421418 data : PeriodIndex | Sequence [Period ],
422- index : AxesData | None = ... ,
419+ index : AxesData | None = None ,
423420 dtype : PeriodDtype = ...,
424- name : Hashable = ... ,
425- copy : bool = ... ,
421+ name : Hashable = None ,
422+ copy : bool | None = None ,
426423 ) -> Series [Period ]: ...
427424 @overload
428425 def __new__ (
429426 cls ,
430427 data : Sequence [BaseOffset ],
431- index : AxesData | None = ... ,
428+ index : AxesData | None = None ,
432429 dtype : PeriodDtype = ...,
433- name : Hashable = ... ,
434- copy : bool = ... ,
430+ name : Hashable = None ,
431+ copy : bool | None = None ,
435432 ) -> Series [BaseOffset ]: ...
436433 @overload
437434 def __new__ (
@@ -443,10 +440,10 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
443440 | np .timedelta64
444441 | timedelta
445442 ),
446- index : AxesData | None = ... ,
443+ index : AxesData | None = None ,
447444 dtype : TimedeltaDtypeArg = ...,
448- name : Hashable = ... ,
449- copy : bool = ... ,
445+ name : Hashable = None ,
446+ copy : bool | None = None ,
450447 ) -> Series [Timedelta ]: ...
451448 @overload
452449 def __new__ (
@@ -457,67 +454,58 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
457454 | Sequence [Interval [_OrderableT ]]
458455 | dict [HashableT1 , Interval [_OrderableT ]]
459456 ),
460- index : AxesData | None = ... ,
457+ index : AxesData | None = None ,
461458 dtype : Literal ["Interval" ] = ...,
462- name : Hashable = ... ,
463- copy : bool = ... ,
459+ name : Hashable = None ,
460+ copy : bool | None = None ,
464461 ) -> Series [Interval [_OrderableT ]]: ...
465462 @overload
466463 def __new__ ( # type: ignore[overload-overlap]
467464 cls ,
468465 data : Scalar | _DataLike | dict [HashableT1 , Any ] | None ,
469- index : AxesData | None = ... ,
466+ index : AxesData | None = None ,
470467 * ,
471468 dtype : type [S1 ],
472- name : Hashable = ... ,
473- copy : bool = ... ,
469+ name : Hashable = None ,
470+ copy : bool | None = None ,
474471 ) -> Self : ...
475472 @overload
476- def __new__ ( # type: ignore[overload-overlap] # pyright: ignore[reportOverlappingOverload]
473+ def __new__ ( # pyright: ignore[reportOverlappingOverload]
477474 cls ,
478- data : Sequence [bool ],
479- index : AxesData | None = ... ,
480- dtype : Dtype = ... ,
481- name : Hashable = ... ,
482- copy : bool = ... ,
475+ data : Sequence [bool | np . bool ],
476+ index : AxesData | None = None ,
477+ dtype : Dtype | None = None ,
478+ name : Hashable = None ,
479+ copy : bool | None = None ,
483480 ) -> Series [bool ]: ...
484481 @overload
485- def __new__ ( # type: ignore[overload-overlap]
482+ def __new__ (
486483 cls ,
487- data : Sequence [int ],
488- index : AxesData | None = ... ,
489- dtype : Dtype = ... ,
490- name : Hashable = ... ,
491- copy : bool = ... ,
484+ data : Sequence [int | np . integer ],
485+ index : AxesData | None = None ,
486+ dtype : Dtype | None = None ,
487+ name : Hashable = None ,
488+ copy : bool | None = None ,
492489 ) -> Series [int ]: ...
493490 @overload
494491 def __new__ (
495492 cls ,
496- data : Sequence [float ],
497- index : AxesData | None = ...,
498- dtype : Dtype = ...,
499- name : Hashable = ...,
500- copy : bool = ...,
501- ) -> Series [float ]: ...
502- @overload
503- def __new__ ( # type: ignore[overload-cannot-match] # pyright: ignore[reportOverlappingOverload]
504- cls ,
505- data : Sequence [int | float ],
506- index : AxesData | None = ...,
507- dtype : Dtype = ...,
508- name : Hashable = ...,
509- copy : bool = ...,
493+ data : Sequence [float | np .floating ] | np_ndarray_float | FloatingArray ,
494+ index : AxesData | None = None ,
495+ dtype : FloatDtypeArg | None = None ,
496+ name : Hashable = None ,
497+ copy : bool | None = None ,
510498 ) -> Series [float ]: ...
511499 @overload
512500 def __new__ (
513501 cls ,
514502 data : (
515503 S1 | _DataLikeS1 [S1 ] | dict [HashableT1 , S1 ] | KeysView [S1 ] | ValuesView [S1 ]
516504 ),
517- index : AxesData | None = ... ,
518- dtype : Dtype = ... ,
519- name : Hashable = ... ,
520- copy : bool = ... ,
505+ index : AxesData | None = None ,
506+ dtype : Dtype | None = None ,
507+ name : Hashable = None ,
508+ copy : bool | None = None ,
521509 ) -> Self : ...
522510 @overload
523511 def __new__ (
@@ -530,11 +518,11 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
530518 | NaTType
531519 | NAType
532520 | None
533- ) = ... ,
534- index : AxesData | None = ... ,
535- dtype : Dtype = ... ,
536- name : Hashable = ... ,
537- copy : bool = ... ,
521+ ) = None ,
522+ index : AxesData | None = None ,
523+ dtype : Dtype | None = None ,
524+ name : Hashable = None ,
525+ copy : bool | None = None ,
538526 ) -> Series : ...
539527 @property
540528 def hasnans (self ) -> bool : ...
@@ -1446,28 +1434,28 @@ class Series(IndexOpsMixin[S1], ElementOpsMixin[S1], NDFrame):
14461434 @overload
14471435 def astype (
14481436 self ,
1449- dtype : FloatDtypeArg ,
1437+ dtype : FloatDtypeArg | PandasAstypeFloatDtypeArg ,
14501438 copy : _bool = ...,
14511439 errors : IgnoreRaise = ...,
14521440 ) -> Series [float ]: ...
14531441 @overload
14541442 def astype (
14551443 self ,
1456- dtype : ComplexDtypeArg ,
1444+ dtype : ComplexDtypeArg | PandasAstypeComplexDtypeArg ,
14571445 copy : _bool = ...,
14581446 errors : IgnoreRaise = ...,
14591447 ) -> Series [complex ]: ...
14601448 @overload
14611449 def astype (
14621450 self ,
1463- dtype : TimedeltaDtypeArg ,
1451+ dtype : TimedeltaDtypeArg | PandasAstypeTimedeltaDtypeArg ,
14641452 copy : _bool = ...,
14651453 errors : IgnoreRaise = ...,
14661454 ) -> Series [Timedelta ]: ...
14671455 @overload
14681456 def astype (
14691457 self ,
1470- dtype : TimestampDtypeArg ,
1458+ dtype : TimestampDtypeArg | PandasAstypeTimestampDtypeArg ,
14711459 copy : _bool = ...,
14721460 errors : IgnoreRaise = ...,
14731461 ) -> Series [Timestamp ]: ...
0 commit comments