Skip to content

Commit e4731ae

Browse files
Fixed apply stubs when using a function returning a set (#599)
1 parent e3d9a1f commit e4731ae

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pandas-stubs/core/series.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ class Series(IndexOpsMixin, NDFrame, Generic[S1]):
761761
@overload
762762
def apply(
763763
self,
764-
func: Callable[..., Scalar | Sequence | Mapping],
764+
func: Callable[..., Scalar | Sequence | set | Mapping],
765765
convertDType: _bool = ...,
766766
args: tuple = ...,
767767
**kwds,

tests/test_series.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,3 +1777,10 @@ def test_check_xs() -> None:
17771777
s4 = pd.Series([1, 4])
17781778
s4.xs(0, axis=0)
17791779
check(assert_type(s4, pd.Series), pd.Series)
1780+
1781+
1782+
def test_types_apply_set() -> None:
1783+
series_of_lists: pd.Series = pd.Series(
1784+
{"list1": [1, 2, 3], "list2": ["a", "b", "c"], "list3": [True, False, True]}
1785+
)
1786+
check(assert_type(series_of_lists.apply(lambda x: set(x)), pd.Series), pd.Series)

0 commit comments

Comments
 (0)