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
@@ -1202,6 +1202,9 @@ def _get_time_delta_bins(self, ax):
1202
1202
raise TypeError ('axis must be a TimedeltaIndex, but got '
1203
1203
'an instance of %r' % type (ax ).__name__ )
1204
1204
1205
+ if len (ax ) > 0 and all (ax ._isnan ):
1206
+ raise DataError ('axis not valid' )
1207
+
1205
1208
if not len (ax ):
1206
1209
binner = labels = TimedeltaIndex (
1207
1210
data = [], freq = self .freq , name = ax .name )
@@ -1223,7 +1226,7 @@ def _get_time_delta_bins(self, ax):
1223
1226
binner = binner .insert (0 , tslib .NaT )
1224
1227
labels = labels .insert (0 , tslib .NaT )
1225
1228
1226
- n_NaT = sum ([ ax_i is tslib . NaT for ax_i in ax ] )
1229
+ n_NaT = ax . _isnan . sum ()
1227
1230
bins = np .insert (bins , 0 , n_NaT )
1228
1231
1229
1232
# Addresses GH #10530
0 commit comments