-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Aggregate mean over TimeDelta column #17382
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
Comments
I think this is just because we don't have a cython implementation of pandas/pandas/_libs/groupby_helper.pxi.in Line 31 in ad7d6fc
FYI, a slightly smaller workaround is |
Oh, it might be a bit more involved than that, since it looks like we call |
The cython path will handle timedeltas as below
Arguably not a great API - we automatically exclude "non-numeric" columns on groupby ops. This makes sense with an entire DataFrame, but perhaps on a Series selection this should default to true? |
@chris-b1 Just tried this on my dataframe, and it does not give me correct results, I think it's because it handles |
This same issue is occurring when using Also, @chris-b1 's workaround worked just fine for me. |
It seems to make sense to convert timestamp column to either days or seconds by using the inbuilt functions to get the mean. |
FWIW (another workaround), you can use ✅ |
this is still an issue for me too, left my head spinning as I was able to get the mean | median values using describe etc. but then when pivoting and group_by started to get |
This look to work on master now. Could use a test
|
Cannot compute mean of timedelta in gropuby
Problem description
The mean of
TimeDelta
can be computed, but it is not working in GroupBy.Expected Output
This is the output I would expect.
Output of
pd.show_versions()
INSTALLED VERSIONS
commit: None
python: 3.6.1.final.0
python-bits: 64
OS: Darwin
OS-release: 16.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.20.3
pytest: None
pip: 9.0.1
setuptools: 27.2.0
Cython: None
numpy: 1.13.1
scipy: 0.19.1
xarray: None
IPython: 6.0.0
sphinx: None
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2017.2
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.2
feather: None
matplotlib: 2.0.2
openpyxl: 2.4.1
xlrd: 1.0.0
xlwt: 1.2.0
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.999
sqlalchemy: 1.1.9
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
pandas_gbq: None
pandas_datareader: 0.2.1
The text was updated successfully, but these errors were encountered: