Skip to content

calling mean on groupby of timedelta does not work #12440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cancan101 opened this issue Feb 24, 2016 · 1 comment
Closed

calling mean on groupby of timedelta does not work #12440

cancan101 opened this issue Feb 24, 2016 · 1 comment
Labels
Groupby Timedelta Timedelta data type

Comments

@cancan101
Copy link
Contributor

Code Sample, a copy-pastable example if possible

This works:

print pd.DataFrame([pd.Timedelta(1)]).groupby(level=0).sum()
                0
0 00:00:00.000000

but this does not:

print pd.DataFrame([pd.Timedelta(1)]).groupby(level=0).mean()
---------------------------------------------------------------------------
DataError                                 Traceback (most recent call last)
<ipython-input-151-ac23f5162583> in <module>()
----> 1 print pd.DataFrame([pd.Timedelta(1)]).groupby(level=0).mean()

/Users/alex/.virtualenvs/work/lib/python2.7/site-packages/pandas/core/groupby.pyc in mean(self)
    758         """
    759         try:
--> 760             return self._cython_agg_general('mean')
    761         except GroupByError:
    762             raise

/Users/alex/.virtualenvs/work/lib/python2.7/site-packages/pandas/core/groupby.pyc in _cython_agg_general(self, how, numeric_only)
   2851 
   2852     def _cython_agg_general(self, how, numeric_only=True):
-> 2853         new_items, new_blocks = self._cython_agg_blocks(how, numeric_only=numeric_only)
   2854         return self._wrap_agged_blocks(new_items, new_blocks)
   2855 

/Users/alex/.virtualenvs/work/lib/python2.7/site-packages/pandas/core/groupby.pyc in _cython_agg_blocks(self, how, numeric_only)
   2896 
   2897         if len(new_blocks) == 0:
-> 2898             raise DataError('No numeric types to aggregate')
   2899 
   2900         return data.items, new_blocks

DataError: No numeric types to aggregate

even though both of these work:

pd.DataFrame([pd.Timedelta(1)]).mean()

and

pd.DataFrame([pd.Timedelta(1)]).sum()

output of pd.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.9.final.0
python-bits: 64
OS: Darwin
OS-release: 14.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: 1.3.6
pip: 1.5.6
setuptools: 3.6
Cython: None
numpy: 1.10.4
scipy: 0.15.1
statsmodels: None
IPython: 3.1.0
sphinx: None
patsy: None
dateutil: 2.4.2
pytz: 2015.7
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.4.3
openpyxl: None
xlrd: 0.9.3
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.4.0
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.11
pymysql: None
psycopg2: 2.6.1 (dt dec pq3 ext lo64)
Jinja2: None
@jreback
Copy link
Contributor

jreback commented Feb 24, 2016

dupe of #5724

@jreback jreback closed this as completed Feb 24, 2016
@jreback jreback added Groupby Timedelta Timedelta data type labels Feb 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Groupby Timedelta Timedelta data type
Projects
None yet
Development

No branches or pull requests

2 participants