@@ -343,7 +343,7 @@ def get_group_levels(self):
343
343
344
344
_cython_arity = {"ohlc" : 4 } # OHLC
345
345
346
- _name_functions = {"ohlc" : lambda * args : ["open" , "high" , "low" , "close" ]}
346
+ _name_functions = {"ohlc" : ["open" , "high" , "low" , "close" ]}
347
347
348
348
def _is_builtin_func (self , arg ):
349
349
"""
@@ -433,6 +433,13 @@ def _cython_operation(
433
433
assert kind in ["transform" , "aggregate" ]
434
434
orig_values = values
435
435
436
+ if values .ndim > 2 :
437
+ raise NotImplementedError ("number of dimensions is currently limited to 2" )
438
+ elif values .ndim == 2 :
439
+ # Note: it is *not* the case that axis is always 0 for 1-dim values,
440
+ # as we can have 1D ExtensionArrays that we need to treat as 2D
441
+ assert axis == 1 , axis
442
+
436
443
# can we do this operation with our cython functions
437
444
# if not raise NotImplementedError
438
445
@@ -545,10 +552,7 @@ def _cython_operation(
545
552
if vdim == 1 and arity == 1 :
546
553
result = result [:, 0 ]
547
554
548
- if how in self ._name_functions :
549
- names = self ._name_functions [how ]() # type: Optional[List[str]]
550
- else :
551
- names = None
555
+ names = self ._name_functions .get (how , None ) # type: Optional[List[str]]
552
556
553
557
if swapped :
554
558
result = result .swapaxes (0 , axis )
@@ -578,10 +582,7 @@ def _aggregate(
578
582
is_datetimelike : bool ,
579
583
min_count : int = - 1 ,
580
584
):
581
- if values .ndim > 2 :
582
- # punting for now
583
- raise NotImplementedError ("number of dimensions is currently limited to 2" )
584
- elif agg_func is libgroupby .group_nth :
585
+ if agg_func is libgroupby .group_nth :
585
586
# different signature from the others
586
587
# TODO: should we be using min_count instead of hard-coding it?
587
588
agg_func (result , counts , values , comp_ids , rank = 1 , min_count = - 1 )
@@ -595,11 +596,7 @@ def _transform(
595
596
):
596
597
597
598
comp_ids , _ , ngroups = self .group_info
598
- if values .ndim > 2 :
599
- # punting for now
600
- raise NotImplementedError ("number of dimensions is currently limited to 2" )
601
- else :
602
- transform_func (result , values , comp_ids , ngroups , is_datetimelike , ** kwargs )
599
+ transform_func (result , values , comp_ids , ngroups , is_datetimelike , ** kwargs )
603
600
604
601
return result
605
602
0 commit comments