Skip to content

Commit 5177d67

Browse files
GH978 Build pd.Series from typed dict (#1000)
* GH978 Build pd.Series from typed dict * Revert accidental deletion
1 parent 708c8aa commit 5177d67

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

pandas-stubs/core/series.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
334334
data: (
335335
Scalar
336336
| _ListLike
337-
| dict[HashableT1, Any]
337+
| Mapping[HashableT1, Any]
338338
| BaseGroupBy
339339
| NaTType
340340
| NAType

tests/test_frame.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3490,3 +3490,15 @@ def test_info() -> None:
34903490
check(assert_type(df.info(show_counts=True), None), type(None))
34913491
check(assert_type(df.info(show_counts=False), None), type(None))
34923492
check(assert_type(df.info(show_counts=None), None), type(None))
3493+
3494+
3495+
def test_series_typed_dict() -> None:
3496+
"""Test that no error is raised when constructing a series from a typed dict."""
3497+
3498+
class MyDict(TypedDict):
3499+
a: str
3500+
b: str
3501+
3502+
my_dict = MyDict(a="", b="")
3503+
sr = pd.Series(my_dict)
3504+
check(assert_type(sr, pd.Series), pd.Series)

0 commit comments

Comments
 (0)