Skip to content

Commit

Permalink
BUG/TST: fixed series apply frozenset error and created test case (#903)
Browse files Browse the repository at this point in the history
* fixed series apply frozenset error and created test case

* added test function for series.apply and removed incorrect test

* added new line after last test

* fixed tests to adhere to check & assert_type way of testing

* fixed pre-commit black issues

* fixed test formatting

* fixed black error in series.pyi
  • Loading branch information
teshao committed Apr 9, 2024
1 parent 0d54b01 commit 9dd9eee
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pandas-stubs/core/series.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,9 @@ class Series(IndexOpsMixin[S1], NDFrame):
@overload
def apply(
self,
func: Callable[..., Scalar | Sequence | set | Mapping | NAType | None],
func: Callable[
..., Scalar | Sequence | set | Mapping | NAType | frozenset | None
],
convertDType: _bool = ...,
args: tuple = ...,
**kwds,
Expand Down
8 changes: 8 additions & 0 deletions tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3083,3 +3083,11 @@ def first_arg_not_series(argument_1: int, ser: pd.Series) -> pd.Series:
),
1,
)


def test_series_apply() -> None:
s = pd.Series(["A", "B", "AB"])
check(assert_type(s.apply(tuple), "pd.Series[Any]"), pd.Series)
check(assert_type(s.apply(list), "pd.Series[Any]"), pd.Series)
check(assert_type(s.apply(set), "pd.Series[Any]"), pd.Series)
check(assert_type(s.apply(frozenset), "pd.Series[Any]"), pd.Series)

0 comments on commit 9dd9eee

Please sign in to comment.