7
7
from pandas .core .base import AbstractMethodError , GroupByMixin
8
8
9
9
from pandas .core .groupby import (BinGrouper , Grouper , _GroupBy , GroupBy ,
10
- SeriesGroupBy , groupby , PanelGroupBy )
10
+ SeriesGroupBy , groupby , PanelGroupBy , DataError )
11
11
12
12
from pandas .tseries .frequencies import to_offset , is_subperiod , is_superperiod
13
13
from pandas .tseries .index import DatetimeIndex , date_range
@@ -1219,6 +1219,9 @@ def _get_time_delta_bins(self, ax):
1219
1219
raise TypeError ('axis must be a TimedeltaIndex, but got '
1220
1220
'an instance of %r' % type (ax ).__name__ )
1221
1221
1222
+ if len (ax ) > 0 and all (ax ._isnan ):
1223
+ raise DataError ('axis not valid' )
1224
+
1222
1225
if not len (ax ):
1223
1226
binner = labels = TimedeltaIndex (
1224
1227
data = [], freq = self .freq , name = ax .name )
@@ -1240,7 +1243,7 @@ def _get_time_delta_bins(self, ax):
1240
1243
binner = binner .insert (0 , tslib .NaT )
1241
1244
labels = labels .insert (0 , tslib .NaT )
1242
1245
1243
- n_NaT = sum ([ ax_i is tslib . NaT for ax_i in ax ] )
1246
+ n_NaT = ax . _isnan . sum ()
1244
1247
bins = np .insert (bins , 0 , n_NaT )
1245
1248
1246
1249
# Addresses GH #10530
0 commit comments