Skip to content

Commit a2ed7b5

Browse files
committed
allow apply to return an offset
1 parent dd8b73a commit a2ed7b5

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

pandas-stubs/core/series.pyi

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,14 @@ class Series(IndexOpsMixin[S1], NDFrame):
10301030
**kwds,
10311031
) -> Series: ...
10321032
@overload
1033+
def apply(
1034+
self,
1035+
func: Callable[..., BaseOffset],
1036+
convertDType: _bool = ...,
1037+
args: tuple = ...,
1038+
**kwds,
1039+
) -> OffsetSeries: ...
1040+
@overload
10331041
def apply(
10341042
self,
10351043
func: Callable[..., Series],

tests/test_series.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3454,3 +3454,14 @@ def test_slice_timestamp() -> None:
34543454
pd.Series,
34553455
np.integer,
34563456
)
3457+
3458+
3459+
def test_apply_dateoffset() -> None:
3460+
# GH 454
3461+
months = [1, 2, 3]
3462+
s = pd.Series(months)
3463+
check(
3464+
assert_type(s.apply(lambda x: pd.DateOffset(months=x)), "OffsetSeries"),
3465+
pd.Series,
3466+
pd.DateOffset,
3467+
)

0 commit comments

Comments
 (0)