Skip to content

Commit 5a2b121

Browse files
committed
support dict keys in constructor to Series
1 parent 79f24c9 commit 5a2b121

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pandas-stubs/core/series.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from collections import dict_keys # type: ignore[attr-defined]
12
from collections.abc import (
23
Callable,
34
Hashable,
@@ -354,7 +355,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
354355
@overload
355356
def __new__(
356357
cls,
357-
data: S1 | _ListLike[S1] | dict[HashableT1, S1],
358+
data: S1 | _ListLike[S1] | dict[HashableT1, S1] | dict_keys[S1, Any],
358359
index: Axes | None = ...,
359360
*,
360361
dtype: Dtype = ...,

tests/test_series.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3529,3 +3529,12 @@ def test_path_div() -> None:
35293529

35303530
folders = pd.Series([folder, folder])
35313531
check(assert_type(folders / Path("a.png"), pd.Series), pd.Series, Path)
3532+
3533+
3534+
def test_series_dict() -> None:
3535+
# GH 812
3536+
check(
3537+
assert_type(pd.Series({"a": 1, "b": 2}.keys()), "pd.Series[str]"),
3538+
pd.Series,
3539+
str,
3540+
)

0 commit comments

Comments
 (0)