@@ -362,13 +362,17 @@ def delete(self, loc):
362362 self .values = np .delete (self .values , loc , 0 )
363363 self .mgr_locs = self .mgr_locs .delete (loc )
364364
365- def apply (self , func , ** kwargs ):
365+ def apply (self , func , ** kwargs ) -> List [ "Block" ] :
366366 """ apply the function to my values; return a block if we are not
367367 one
368368 """
369369 with np .errstate (all = "ignore" ):
370370 result = func (self .values , ** kwargs )
371371
372+ return self ._split_op_result (result )
373+
374+ def _split_op_result (self , result ) -> List ["Block" ]:
375+ # See also: split_and_operate
372376 if is_extension_array_dtype (result ) and result .ndim > 1 :
373377 # if we get a 2D ExtensionArray, we need to split it into 1D pieces
374378 nbs = []
@@ -382,7 +386,7 @@ def apply(self, func, **kwargs):
382386 if not isinstance (result , Block ):
383387 result = self .make_block (values = _block_shape (result , ndim = self .ndim ))
384388
385- return result
389+ return [ result ]
386390
387391 def fillna (self , value , limit = None , inplace = False , downcast = None ):
388392 """ fillna on the block with the value. If we fail, then convert to
0 commit comments