Skip to content

[Python] Support arithmetic on arrays and scalars #32007

@asfimport

Description

@asfimport

I was surprised to find you can't use standard arithmetic operators on PyArrow arrays and scalars. Instead, one must use the compute functions:

import pyarrow as pa

arr = pa.array([1, 2, 3])
pc.add(arr, 2)
# Doesn't work:
# arr + 2
# arr + pa.scalar(2)
# arr + arr

pc.multiply(arr, 20)
# Doesn't work:
# 20 * arr
# pa.scalar(20) * arr

Is it intentional we don't support this?

Reporter: Will Jones / @wjones127
Watchers: Rok Mihevc / @rok

Note: This issue was originally created as ARROW-16658. Please see the migration documentation for further details.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions