@@ -489,7 +489,11 @@ def _binary_op(self, other, f, reflexive=False):
489
489
# import IPython; IPython.core.debugger.set_trace()
490
490
try :
491
491
if self ._bins is not None :
492
- other = other .sel ({f"{ name } _bins" : self ._group })
492
+ if self ._stacked_dim is not None :
493
+ group = self ._group .unstack ()
494
+ # idx = pd.factorize(group.data.ravel())[0]
495
+ # group_idx = group.copy(data=idx.reshape(group.data.shape))
496
+ other = other .sel ({f"{ name } _bins" : group })
493
497
if isinstance (group , _DummyGroup ):
494
498
# When binning by unindexed coordinate we need to reindex obj.
495
499
# _full_index is IntervalIndex, so idx will be -1 where
@@ -525,13 +529,12 @@ def _binary_op(self, other, f, reflexive=False):
525
529
526
530
result = g (obj , other )
527
531
528
- # backcompat: concat during the "combine" step places
529
- # `dim` as the first dimension
530
- if dim in result .dims :
531
- # guards against self._group_dim being "stacked"
532
- result = result .transpose (dim , ...)
533
- # for var in set(obj.coords) - set(obj.xindexes):
534
- # result[var] = result[var].broadcast_like(other)
532
+ # backcompat:
533
+ for var in set (obj .coords ) - set (obj .xindexes ):
534
+ print (var )
535
+ if dim not in obj [var ]:
536
+ print (f"excluding { dim } , broadcasting { var } " )
537
+ result [var ] = obj [var ].reset_coords (drop = True ).broadcast_like (result )
535
538
return result
536
539
537
540
def _maybe_restore_empty_groups (self , combined ):
0 commit comments