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
@@ -1189,6 +1189,9 @@ def _get_time_delta_bins(self, ax):
1189
1189
raise TypeError ('axis must be a TimedeltaIndex, but got '
1190
1190
'an instance of %r' % type (ax ).__name__ )
1191
1191
1192
+ if len (ax ) > 0 and all (ax ._isnan ):
1193
+ raise DataError ('axis not valid' )
1194
+
1192
1195
if not len (ax ):
1193
1196
binner = labels = TimedeltaIndex (
1194
1197
data = [], freq = self .freq , name = ax .name )
@@ -1210,7 +1213,7 @@ def _get_time_delta_bins(self, ax):
1210
1213
binner = binner .insert (0 , tslib .NaT )
1211
1214
labels = labels .insert (0 , tslib .NaT )
1212
1215
1213
- n_NaT = sum ([ ax_i is tslib . NaT for ax_i in ax ] )
1216
+ n_NaT = ax . _isnan . sum ()
1214
1217
bins = np .insert (bins , 0 , n_NaT )
1215
1218
1216
1219
# Addresses GH #10530
0 commit comments