Skip to content

Commit

Permalink
GH978 Build pd.Series from typed dict (#1000)
Browse files Browse the repository at this point in the history
* GH978 Build pd.Series from typed dict

* Revert accidental deletion
  • Loading branch information
loicdiridollou authored Sep 13, 2024
1 parent 708c8aa commit 5177d67
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class Series(IndexOpsMixin[S1], NDFrame):
data: (
Scalar
| _ListLike
| dict[HashableT1, Any]
| Mapping[HashableT1, Any]
| BaseGroupBy
| NaTType
| NAType
Expand Down
12 changes: 12 additions & 0 deletions tests/test_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -3490,3 +3490,15 @@ def test_info() -> None:
check(assert_type(df.info(show_counts=True), None), type(None))
check(assert_type(df.info(show_counts=False), None), type(None))
check(assert_type(df.info(show_counts=None), None), type(None))


def test_series_typed_dict() -> None:
"""Test that no error is raised when constructing a series from a typed dict."""

class MyDict(TypedDict):
a: str
b: str

my_dict = MyDict(a="", b="")
sr = pd.Series(my_dict)
check(assert_type(sr, pd.Series), pd.Series)

0 comments on commit 5177d67

Please sign in to comment.