25
25
notnull , _DATELIKE_DTYPES , is_numeric_dtype ,
26
26
is_timedelta64_dtype , is_datetime64_dtype ,
27
27
is_categorical_dtype , _values_from_object ,
28
- is_datetime_or_timedelta_dtype , is_bool_dtype )
28
+ is_datetime_or_timedelta_dtype , is_bool_dtype ,
29
+ AbstractMethodError )
29
30
from pandas .core .config import option_context
30
31
import pandas .lib as lib
31
32
from pandas .lib import Timestamp
@@ -279,7 +280,7 @@ def _set_grouper(self, obj, sort=False):
279
280
return self .grouper
280
281
281
282
def _get_binner_for_grouping (self , obj ):
282
- raise NotImplementedError
283
+ raise AbstractMethodError ( self )
283
284
284
285
@property
285
286
def groups (self ):
@@ -670,7 +671,7 @@ def _python_apply_general(self, f):
670
671
not_indexed_same = mutated )
671
672
672
673
def aggregate (self , func , * args , ** kwargs ):
673
- raise NotImplementedError
674
+ raise AbstractMethodError ( self )
674
675
675
676
@Appender (_agg_doc )
676
677
def agg (self , func , * args , ** kwargs ):
@@ -680,7 +681,7 @@ def _iterate_slices(self):
680
681
yield self .name , self ._selected_obj
681
682
682
683
def transform (self , func , * args , ** kwargs ):
683
- raise NotImplementedError
684
+ raise AbstractMethodError ( self )
684
685
685
686
def mean (self ):
686
687
"""
@@ -1127,7 +1128,7 @@ def _python_agg_general(self, func, *args, **kwargs):
1127
1128
return self ._wrap_aggregated_output (output )
1128
1129
1129
1130
def _wrap_applied_output (self , * args , ** kwargs ):
1130
- raise NotImplementedError
1131
+ raise AbstractMethodError ( self )
1131
1132
1132
1133
def _concat_objects (self , keys , values , not_indexed_same = False ):
1133
1134
from pandas .tools .merge import concat
@@ -1484,7 +1485,8 @@ def aggregate(self, values, how, axis=0):
1484
1485
swapped = True
1485
1486
values = values .swapaxes (0 , axis )
1486
1487
if arity > 1 :
1487
- raise NotImplementedError
1488
+ raise NotImplementedError ("arity of more than 1 is not "
1489
+ "supported for the 'how' argument" )
1488
1490
out_shape = (self .ngroups ,) + values .shape [1 :]
1489
1491
1490
1492
is_numeric = is_numeric_dtype (values .dtype )
@@ -1556,7 +1558,8 @@ def _aggregate(self, result, counts, values, agg_func, is_numeric):
1556
1558
comp_ids , _ , ngroups = self .group_info
1557
1559
if values .ndim > 3 :
1558
1560
# punting for now
1559
- raise NotImplementedError
1561
+ raise NotImplementedError ("number of dimensions is currently "
1562
+ "limited to 3" )
1560
1563
elif values .ndim > 2 :
1561
1564
for i , chunk in enumerate (values .transpose (2 , 0 , 1 )):
1562
1565
@@ -1815,7 +1818,8 @@ def _aggregate(self, result, counts, values, agg_func, is_numeric=True):
1815
1818
1816
1819
if values .ndim > 3 :
1817
1820
# punting for now
1818
- raise NotImplementedError
1821
+ raise NotImplementedError ("number of dimensions is currently "
1822
+ "limited to 3" )
1819
1823
elif values .ndim > 2 :
1820
1824
for i , chunk in enumerate (values .transpose (2 , 0 , 1 )):
1821
1825
agg_func (result [:, :, i ], counts , chunk , self .bins )
@@ -2622,7 +2626,8 @@ def aggregate(self, arg, *args, **kwargs):
2622
2626
if self ._selection is not None :
2623
2627
subset = obj
2624
2628
if isinstance (subset , DataFrame ):
2625
- raise NotImplementedError
2629
+ raise NotImplementedError ("Aggregating on a DataFrame is "
2630
+ "not supported" )
2626
2631
2627
2632
for fname , agg_how in compat .iteritems (arg ):
2628
2633
colg = SeriesGroupBy (subset , selection = self ._selection ,
@@ -2671,7 +2676,7 @@ def _aggregate_multiple_funcs(self, arg):
2671
2676
from pandas .tools .merge import concat
2672
2677
2673
2678
if self .axis != 0 :
2674
- raise NotImplementedError
2679
+ raise NotImplementedError ( "axis other than 0 is not supported" )
2675
2680
2676
2681
obj = self ._obj_with_exclusions
2677
2682
@@ -2721,7 +2726,7 @@ def _aggregate_generic(self, func, *args, **kwargs):
2721
2726
return self ._wrap_generic_output (result , obj )
2722
2727
2723
2728
def _wrap_aggregated_output (self , output , names = None ):
2724
- raise NotImplementedError
2729
+ raise AbstractMethodError ( self )
2725
2730
2726
2731
def _aggregate_item_by_item (self , func , * args , ** kwargs ):
2727
2732
# only for axis==0
@@ -3283,7 +3288,7 @@ def _iterate_slices(self):
3283
3288
slice_axis = self ._selection_list
3284
3289
slicer = lambda x : self ._selected_obj [x ]
3285
3290
else :
3286
- raise NotImplementedError
3291
+ raise NotImplementedError ( "axis other than 0 is not supported" )
3287
3292
3288
3293
for val in slice_axis :
3289
3294
if val in self .exclusions :
@@ -3348,10 +3353,10 @@ def _aggregate_item_by_item(self, func, *args, **kwargs):
3348
3353
new_axes [self .axis ] = self .grouper .result_index
3349
3354
return Panel ._from_axes (result , new_axes )
3350
3355
else :
3351
- raise NotImplementedError
3356
+ raise ValueError ( "axis value must be greater than 0" )
3352
3357
3353
3358
def _wrap_aggregated_output (self , output , names = None ):
3354
- raise NotImplementedError
3359
+ raise AbstractMethodError ( self )
3355
3360
3356
3361
3357
3362
class NDArrayGroupBy (GroupBy ):
@@ -3405,7 +3410,7 @@ def _chop(self, sdata, slice_obj):
3405
3410
return sdata .iloc [slice_obj ]
3406
3411
3407
3412
def apply (self , f ):
3408
- raise NotImplementedError
3413
+ raise AbstractMethodError ( self )
3409
3414
3410
3415
3411
3416
class ArraySplitter (DataSplitter ):
0 commit comments