@@ -362,13 +362,17 @@ def delete(self, loc):
362
362
self .values = np .delete (self .values , loc , 0 )
363
363
self .mgr_locs = self .mgr_locs .delete (loc )
364
364
365
- def apply (self , func , ** kwargs ):
365
+ def apply (self , func , ** kwargs ) -> List [ "Block" ] :
366
366
""" apply the function to my values; return a block if we are not
367
367
one
368
368
"""
369
369
with np .errstate (all = "ignore" ):
370
370
result = func (self .values , ** kwargs )
371
371
372
+ return self ._split_op_result (result )
373
+
374
+ def _split_op_result (self , result ) -> List ["Block" ]:
375
+ # See also: split_and_operate
372
376
if is_extension_array_dtype (result ) and result .ndim > 1 :
373
377
# if we get a 2D ExtensionArray, we need to split it into 1D pieces
374
378
nbs = []
@@ -382,7 +386,7 @@ def apply(self, func, **kwargs):
382
386
if not isinstance (result , Block ):
383
387
result = self .make_block (values = _block_shape (result , ndim = self .ndim ))
384
388
385
- return result
389
+ return [ result ]
386
390
387
391
def fillna (self , value , limit = None , inplace = False , downcast = None ):
388
392
""" fillna on the block with the value. If we fail, then convert to
0 commit comments