@@ -378,23 +378,13 @@ def _prep_values(self, values: Optional[np.ndarray] = None) -> np.ndarray:
378
378
379
379
return values
380
380
381
- def _wrap_result (self , result , block = None , obj = None ) :
381
+ def _wrap_result (self , result : np . ndarray ) -> "Series" :
382
382
"""
383
- Wrap a single result.
383
+ Wrap a single 1D result.
384
384
"""
385
- if obj is None :
386
- obj = self ._selected_obj
387
- index = obj .index
385
+ obj = self ._selected_obj
388
386
389
- if isinstance (result , np .ndarray ):
390
-
391
- if result .ndim == 1 :
392
- from pandas import Series
393
-
394
- return Series (result , index , name = obj .name )
395
-
396
- return type (obj )(result , index = index , columns = block .columns )
397
- return result
387
+ return obj ._constructor (result , obj .index , name = obj .name )
398
388
399
389
def _insert_on_column (self , result : "DataFrame" , obj : "DataFrame" ):
400
390
# if we have an 'on' column we want to put it back into
@@ -421,7 +411,7 @@ def _insert_on_column(self, result: "DataFrame", obj: "DataFrame"):
421
411
# insert at the end
422
412
result [name ] = extra_col
423
413
424
- def _center_window (self , result , window ) -> np .ndarray :
414
+ def _center_window (self , result : np . ndarray , window ) -> np .ndarray :
425
415
"""
426
416
Center the result in the window.
427
417
"""
@@ -480,7 +470,6 @@ def _apply_series(self, homogeneous_func: Callable[..., ArrayLike]) -> "Series":
480
470
Series version of _apply_blockwise
481
471
"""
482
472
_ , obj = self ._create_blocks (self ._selected_obj )
483
- values = obj .values
484
473
485
474
try :
486
475
values = self ._prep_values (obj .values )
@@ -502,7 +491,7 @@ def _apply_blockwise(
502
491
503
492
# This isn't quite blockwise, since `blocks` is actually a collection
504
493
# of homogenenous DataFrames.
505
- blocks , obj = self ._create_blocks (self ._selected_obj )
494
+ _ , obj = self ._create_blocks (self ._selected_obj )
506
495
mgr = obj ._mgr
507
496
508
497
def hfunc (bvalues : ArrayLike ) -> ArrayLike :
0 commit comments