pydata/pandas — pull request #6884 by danielballan (2014-04-14 21:29:37+00:00)
Title: ENH: Allow aggregate numeric operations on timedelta64.

Currently, `timedelta64` columns can't be used in aggregate group operations. They are quietly dropped or, if no other columns are present, an exception is raised:

In [2]: df
Out[2]:
A E
0 foo 00:00:01
1 bar 00:00:02
2 foo 00:00:03
3 bar 00:00:04

In [3]: df.groupby('A').mean()
Out[3]:
(...)
DataError: No numeric types to aggregate

But any operation that works on numerical data is also well defined on timedeltas. This PR relaxes the restriction on those methods designated "numeric only" to accept numeric dtypes *and* `timedelta64`. I include a unit test with one simple case each for `DataFrameGroupBy` and `SeriesGroupBy`.

In [2]: df.groupby('A').mean()
Out[2]:

DataError: No numeric types to aggregate
E
A
bar 00:00:03
foo 00:00:02