@@ -924,7 +924,9 @@ def _make_wrapper(self, name: str) -> Callable:
924
924
# as are not passed directly but in the grouper
925
925
f = getattr (self ._obj_with_exclusions , name )
926
926
if not isinstance (f , types .MethodType ):
927
- return self .apply (lambda self : getattr (self , name ))
927
+ # error: Incompatible return value type
928
+ # (got "NDFrameT", expected "Callable[..., Any]") [return-value]
929
+ return cast (Callable , self .apply (lambda self : getattr (self , name )))
928
930
929
931
f = getattr (type (self ._obj_with_exclusions ), name )
930
932
sig = inspect .signature (f )
@@ -1350,7 +1352,7 @@ def _aggregate_with_numba(self, data, func, *args, engine_kwargs=None, **kwargs)
1350
1352
input = "dataframe" , examples = _apply_docs ["dataframe_examples" ]
1351
1353
)
1352
1354
)
1353
- def apply (self , func , * args , ** kwargs ):
1355
+ def apply (self , func , * args , ** kwargs ) -> NDFrameT :
1354
1356
1355
1357
func = com .is_builtin_func (func )
1356
1358
@@ -1410,7 +1412,7 @@ def _python_apply_general(
1410
1412
f : Callable ,
1411
1413
data : DataFrame | Series ,
1412
1414
not_indexed_same : bool | None = None ,
1413
- ) -> DataFrame | Series :
1415
+ ) -> NDFrameT :
1414
1416
"""
1415
1417
Apply function f in python space
1416
1418
@@ -1812,7 +1814,7 @@ def all(self, skipna: bool = True):
1812
1814
@final
1813
1815
@Substitution (name = "groupby" )
1814
1816
@Appender (_common_see_also )
1815
- def count (self ) -> Series | DataFrame :
1817
+ def count (self ) -> NDFrameT :
1816
1818
"""
1817
1819
Compute count of group, excluding missing values.
1818
1820
@@ -3467,7 +3469,7 @@ def shift(self, periods=1, freq=None, axis=0, fill_value=None):
3467
3469
@final
3468
3470
@Substitution (name = "groupby" )
3469
3471
@Appender (_common_see_also )
3470
- def diff (self , periods : int = 1 , axis : int = 0 ) -> Series | DataFrame :
3472
+ def diff (self , periods : int = 1 , axis : int = 0 ) -> NDFrameT :
3471
3473
"""
3472
3474
First discrete difference of element.
3473
3475
0 commit comments