Skip to content

Commit d2ffa32

Browse files
authored
Enable construction of pd.Series with NaT and NA (#874)
* Enable construction of pd.Series with NaT and NA * cleanup
1 parent 82ed4f1 commit d2ffa32

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pandas-stubs/core/series.pyi

+10-1
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ from pandas._libs.interval import (
9090
from pandas._libs.lib import NoDefault
9191
from pandas._libs.missing import NAType
9292
from pandas._libs.tslibs import BaseOffset
93+
from pandas._libs.tslibs.nattype import NaTType
9394
from pandas._typing import (
9495
S1,
9596
AggFuncTypeBase,
@@ -318,7 +319,15 @@ class Series(IndexOpsMixin[S1], NDFrame):
318319
@overload
319320
def __new__(
320321
cls,
321-
data: Scalar | _ListLike | dict[HashableT1, Any] | BaseGroupBy | None = ...,
322+
data: (
323+
Scalar
324+
| _ListLike
325+
| dict[HashableT1, Any]
326+
| BaseGroupBy
327+
| NaTType
328+
| NAType
329+
| None
330+
) = ...,
322331
index: Axes | None = ...,
323332
*,
324333
dtype: Dtype = ...,

tests/test_series.py

+2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def test_types_init() -> None:
8181
pd.Series(1)
8282
pd.Series((1, 2, 3))
8383
pd.Series(np.array([1, 2, 3]))
84+
pd.Series(pd.NaT)
85+
pd.Series(pd.NA)
8486
pd.Series(data=[1, 2, 3, 4], name="series")
8587
pd.Series(data=[1, 2, 3, 4], dtype=np.int8)
8688
pd.Series(data={"row1": [1, 2], "row2": [3, 4]})

0 commit comments

Comments
 (0)