Skip to content

Commit

Permalink
Enable construction of pd.Series with NaT and NA (#874)
Browse files Browse the repository at this point in the history
* Enable construction of pd.Series with NaT and NA

* cleanup
  • Loading branch information
mark-thm authored Feb 21, 2024
1 parent 82ed4f1 commit d2ffa32
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ from pandas._libs.interval import (
from pandas._libs.lib import NoDefault
from pandas._libs.missing import NAType
from pandas._libs.tslibs import BaseOffset
from pandas._libs.tslibs.nattype import NaTType
from pandas._typing import (
S1,
AggFuncTypeBase,
Expand Down Expand Up @@ -318,7 +319,15 @@ class Series(IndexOpsMixin[S1], NDFrame):
@overload
def __new__(
cls,
data: Scalar | _ListLike | dict[HashableT1, Any] | BaseGroupBy | None = ...,
data: (
Scalar
| _ListLike
| dict[HashableT1, Any]
| BaseGroupBy
| NaTType
| NAType
| None
) = ...,
index: Axes | None = ...,
*,
dtype: Dtype = ...,
Expand Down
2 changes: 2 additions & 0 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ def test_types_init() -> None:
pd.Series(1)
pd.Series((1, 2, 3))
pd.Series(np.array([1, 2, 3]))
pd.Series(pd.NaT)
pd.Series(pd.NA)
pd.Series(data=[1, 2, 3, 4], name="series")
pd.Series(data=[1, 2, 3, 4], dtype=np.int8)
pd.Series(data={"row1": [1, 2], "row2": [3, 4]})
Expand Down

0 comments on commit d2ffa32

Please sign in to comment.