apache / apache/arrow

[Python] Possible follow-up on arithmetic support

Open
#49,606 4 comments 0 reactions 0 assignees View on GitHub
Component: Python Type: enhancement
Dominant language
C++
Stars
17.1k
Forks
4.3k
Avg merge
3d 13h
Merged PRs (30d)
88

Description

### Describe the enhancement requested

Basic arithmetic on arrays and scalars has been added here: https://github.com/apache/arrow/pull/48085.

There are few things that we might work on as a follow-up in case there are requests/interest.

### `& `/ `|` operators and bool type

From https://github.com/apache/arrow/pull/48085#issuecomment-3654526351:

> The & / | operators are currently mapped to the bitwise kernels, but in array-land, I think the most common use case for those is actually for logical (boolean) operations. So as a user, I would expect those to also work on bool type.

- Newly added `&` / `|` operators are not working on boolean arrays/scalars due to kernels only supporting integer types,
- Think about using logical kernels ([`pc.and_`](https://arrow.apache.org/docs/python/generated/pyarrow.compute.and_.html)/[`pc.or_`](https://arrow.apache.org/docs/python/generated/pyarrow.compute.or_.html)) if the input is bool.

### Math-related dunder methods

We have moved math-related dunder methods out of the PR that added support for basic arithmetic:
- https://github.com/apache/arrow/pull/48085
- https://github.com/apache/arrow/pull/48085/changes/72390ed291a60e68418caf742b783bd4124a73c6
- https://github.com/apache/arrow/pull/48085/changes/b76554939ede31bda907f1400753788bcd64e6d4

These methods could also be supported if needed.

### Component(s)

Python

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.