Skip to content

BUG: Pandas 2.1.0 and Arrow 13: "Function 'divide' has no kernel matching input types" for durations #55020

Closed
@bnavigator

Description

@bnavigator

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

pip install 'pyarrow>=13'
pip install 'pandas[test]==2.1.0'
pytest --pyargs pandas -k "TestBaseArithmeticOps and div and duration"

Issue Description

The Pandas 2.1.0 test suite tries to test a functionality of pyarrow which is only introduced in the upcoming v14, not in current v13. A quick incomplete glance at the GitHub Actions CI indicated to me that you test with pyarrow 9 and not yet stable arrow 14, but not with current pyarrow 13.0.0

=================================================================== test session starts ====================================================================
platform linux -- Python 3.11.4, pytest-7.4.1, pluggy-1.3.0
rootdir: /home/ben/tmp
plugins: xdist-3.3.1, asyncio-0.21.1, hypothesis-6.84.1
asyncio: mode=Mode.STRICT
collected 228801 items / 228721 deselected / 54 skipped / 80 selected                                                                                      

penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py ................................FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF [ 93%]
FFFFF                                                                                                                                                [100%]

========================================================================= FAILURES =========================================================================
______________________________________ TestBaseArithmeticOps.test_arith_series_with_scalar[__floordiv__-duration[s]] _______________________________________

self = <pandas.tests.extension.test_arrow.TestBaseArithmeticOps object at 0x7f7fd2bea310>
data = <ArrowExtensionArray>
[   Timedelta('1 days 00:00:00'),    Timedelta('1 days 00:00:01'),
    Timedelta('1 days 00:00:0...      <NA>,
 Timedelta('-10 days +00:00:00'),   Timedelta('10 days 00:00:00')]
Length: 100, dtype: duration[s][pyarrow]
all_arithmetic_operators = '__floordiv__', request = <FixtureRequest for <Function test_arith_series_with_scalar[__floordiv__-duration[s]]>>

    def test_arith_series_with_scalar(self, data, all_arithmetic_operators, request):
        pa_dtype = data.dtype.pyarrow_dtype
    
        if all_arithmetic_operators == "__rmod__" and (
            pa.types.is_string(pa_dtype) or pa.types.is_binary(pa_dtype)
        ):
            pytest.skip("Skip testing Python string formatting")
    
        mark = self._get_arith_xfail_marker(all_arithmetic_operators, pa_dtype)
        if mark is not None:
            request.node.add_marker(mark)
    
>       super().test_arith_series_with_scalar(data, all_arithmetic_operators)

penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py:1075: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
penv/lib64/python3.11/site-packages/pandas/tests/extension/base/ops.py:133: in test_arith_series_with_scalar
    self.check_opname(ser, op_name, ser.iloc[0])
penv/lib64/python3.11/site-packages/pandas/tests/extension/base/ops.py:59: in check_opname
    self._check_op(ser, op, other, op_name, exc)
penv/lib64/python3.11/site-packages/pandas/tests/extension/base/ops.py:81: in _check_op
    result = op(ser, other)
penv/lib64/python3.11/site-packages/pandas/core/ops/common.py:76: in new_method
    return method(self, other)
penv/lib64/python3.11/site-packages/pandas/core/arraylike.py:218: in __floordiv__
    return self._arith_method(other, operator.floordiv)
penv/lib64/python3.11/site-packages/pandas/core/series.py:5820: in _arith_method
    return base.IndexOpsMixin._arith_method(self, other, op)
penv/lib64/python3.11/site-packages/pandas/core/base.py:1381: in _arith_method
    result = ops.arithmetic_op(lvalues, rvalues, op)
penv/lib64/python3.11/site-packages/pandas/core/ops/array_ops.py:275: in arithmetic_op
    res_values = op(left, right)
penv/lib64/python3.11/site-packages/pandas/core/ops/common.py:76: in new_method
    return method(self, other)
penv/lib64/python3.11/site-packages/pandas/core/arraylike.py:218: in __floordiv__
    return self._arith_method(other, operator.floordiv)
penv/lib64/python3.11/site-packages/pandas/core/arrays/arrow/array.py:684: in _arith_method
    return self._evaluate_op_method(other, op, ARROW_ARITHMETIC_FUNCS)
penv/lib64/python3.11/site-packages/pandas/core/arrays/arrow/array.py:672: in _evaluate_op_method
    result = pc_func(self._pa_array, other)
penv/lib64/python3.11/site-packages/pandas/core/arrays/arrow/array.py:130: in <lambda>
    "floordiv": lambda x, y: floordiv_compat(x, y),
penv/lib64/python3.11/site-packages/pandas/core/arrays/arrow/array.py:116: in floordiv_compat
    result = pc.floor(pc.divide(left, right))
penv/lib64/python3.11/site-packages/pyarrow/compute.py:245: in wrapper
    return func.call(args, None, memory_pool)
pyarrow/_compute.pyx:367: in pyarrow._compute.Function.call
    ???
pyarrow/error.pxi:144: in pyarrow.lib.pyarrow_internal_check_status
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])

pyarrow/error.pxi:121: ArrowNotImplementedError

[...]

================================================================= short test summary info ==================================================================
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__floordiv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__floordiv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__floordiv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__floordiv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__rfloordiv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__rfloordiv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__rfloordiv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__rfloordiv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__truediv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__truediv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__truediv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__truediv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__rtruediv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__rtruediv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__rtruediv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_scalar[__rtruediv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__floordiv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__floordiv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__floordiv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__floordiv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__rfloordiv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__rfloordiv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__rfloordiv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__rfloordiv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__truediv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__truediv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__truediv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__truediv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__rtruediv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__rtruediv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__rtruediv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_frame_with_scalar[__rtruediv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__floordiv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__floordiv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__floordiv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__floordiv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__rfloordiv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__rfloordiv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__rfloordiv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__rfloordiv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__truediv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__truediv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__truediv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__truediv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__rtruediv__-duration[s]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[s], duration[s])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__rtruediv__-duration[ms]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ms], duration[ms])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__rtruediv__-duration[us]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[us], duration[us])
FAILED penv/lib64/python3.11/site-packages/pandas/tests/extension/test_arrow.py::TestBaseArithmeticOps::test_arith_series_with_array[__rtruediv__-duration[ns]] - pyarrow.lib.ArrowNotImplementedError: Function 'divide' has no kernel matching input types (duration[ns], duration[ns])
======================================= 48 failed, 32 passed, 54 skipped, 228721 deselected, 200 warnings in 49.01s ========================================

Arrow 12.0.0 is okay in this regard

Expected Behavior

Successful test suite / correct division of durations with pyarrow backend.

Installed Versions


commit : ba1cccd
python : 3.11.4.final.0
python-bits : 64
OS : Linux
OS-release : 6.4.11-1-default
Version : #1 SMP PREEMPT_DYNAMIC Thu Aug 17 04:57:43 UTC 2023 (2a5b3f6)
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : de_DE.UTF-8
LOCALE : de_DE.UTF-8

pandas : 2.1.0
numpy : 1.25.2
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 65.5.0
pip : 23.1.2
Cython : None
pytest : 7.4.1
hypothesis : 6.84.1
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader : None
bs4 : None
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 13.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arrowpyarrow functionalityBug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions