File tree 1 file changed +18
-10
lines changed
1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -474,18 +474,19 @@ def compute_dict_like(
474
474
elif is_groupby :
475
475
# key used for column selection and output
476
476
477
- df = obj . obj
477
+ df = selected_obj
478
478
results , keys = [], []
479
479
for key , how in func .items ():
480
- for index in range ( df . shape [ 1 ]):
481
- col = df . iloc [:, index ]
482
- if col . name != key :
483
- continue
480
+ cols = df [ key ]
481
+
482
+ for index in range ( cols . shape [ 1 ]) :
483
+ col = cols . iloc [:, index ]
484
484
485
485
series = obj ._gotitem (key , ndim = 1 , subset = col )
486
486
result = getattr (series , op_name )(how , ** kwargs )
487
487
results .append (result )
488
488
keys .append (key )
489
+
489
490
else :
490
491
results = [
491
492
getattr (obj ._gotitem (key , ndim = 1 ), op_name )(how , ** kwargs )
@@ -525,11 +526,18 @@ def wrap_results_dict_like(
525
526
keys_to_use = ktu
526
527
527
528
axis : AxisInt = 0 if isinstance (obj , ABCSeries ) else 1
528
- result = concat (
529
- results ,
530
- axis = axis ,
531
- keys = keys_to_use ,
532
- )
529
+ if len (keys_to_use ) == 0 :
530
+ result = concat (
531
+ results ,
532
+ axis = axis ,
533
+ )
534
+ else :
535
+ result = concat (
536
+ results ,
537
+ axis = axis ,
538
+ keys = keys_to_use ,
539
+ )
540
+
533
541
elif any (is_ndframe ):
534
542
# There is a mix of NDFrames and scalars
535
543
raise ValueError (
You can’t perform that action at this time.
0 commit comments