You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
BUG: Cannot call np.median on datetime array #26216
Traceback (most recent call last):
File "<stdin>", line 1, in<module>
File "<__array_function__ internals>", line 180, in median
File "/Users/guilhermeleobas/micromamba/envs/numba/lib/python3.9/site-packages/numpy/lib/function_base.py", line 3793, in median
r, k = _ureduce(a, func=_median, axis=axis, out=out,
File "/Users/guilhermeleobas/micromamba/envs/numba/lib/python3.9/site-packages/numpy/lib/function_base.py", line 3702, in _ureduce
r = func(a, **kwargs)
File "/Users/guilhermeleobas/micromamba/envs/numba/lib/python3.9/site-packages/numpy/lib/function_base.py", line 3847, in _median
rout = mean(part[indexer], axis=axis, out=out)
File "<__array_function__ internals>", line 180, in mean
File "/Users/guilhermeleobas/micromamba/envs/numba/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 3474, in mean
return _methods._mean(a, axis=axis, dtype=dtype,
File "/Users/guilhermeleobas/micromamba/envs/numba/lib/python3.9/site-packages/numpy/core/_methods.py", line 179, in _mean
ret = umr_sum(arr, axis, dtype, out, keepdims, where=where)
numpy.core._exceptions._UFuncBinaryResolutionError: ufunc 'add' cannot use operands with types dtype('<M8[D]') and dtype('<M8[D]')
Python and NumPy Versions:
1.22.4
3.9.18 | packaged by conda-forge | (main, Dec 23 2023, 16:35:41)
[Clang 16.0.6 ]
This may need a bit of thought/discussion (i.e. may be a bit slow). Since similar things happen in mean also. You cannot implement mean as sum()/count or the interpolation here using addition for datetimes.
OTOH, if you can rephrase the computation to support it without breaking/slowing down the (fragile) logic for other types, I think that would definitely be OK.
(Although, maybe nobody will mind a small special case for datetimes.)
Activity
mwanink commentedon Apr 6, 2024
I could take a look at this if nobody else has yet!
seberg commentedon Apr 10, 2024
This may need a bit of thought/discussion (i.e. may be a bit slow). Since similar things happen in
meanalso. You cannot implement mean assum()/countor the interpolation here using addition for datetimes.OTOH, if you can rephrase the computation to support it without breaking/slowing down the (fragile) logic for other types, I think that would definitely be OK.
(Although, maybe nobody will mind a small special case for datetimes.)
kasmith11 commentedon Apr 29, 2024
@seberg is this still an open discussion? If so, do you feel as if this would be a good first contribution?