You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Alessandro Molina (Jira)" <ji...@apache.org> on 2022/06/07 12:45:00 UTC

[jira] [Commented] (ARROW-16658) [Python] Support arithmetic on arrays and scalars

    [ https://issues.apache.org/jira/browse/ARROW-16658?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17550979#comment-17550979 ] 

Alessandro Molina commented on ARROW-16658:
-------------------------------------------

I think it's reasonable to add those operators to Arrays. In the end we already provide those features, it's not that we would be implementing something new.
I think relying on operators to manipulate arrays is a spread enough pattern in Python that it's a good idea to support it.

> [Python] Support arithmetic on arrays and scalars
> -------------------------------------------------
>
>                 Key: ARROW-16658
>                 URL: https://issues.apache.org/jira/browse/ARROW-16658
>             Project: Apache Arrow
>          Issue Type: Wish
>          Components: Python
>    Affects Versions: 8.0.0
>            Reporter: Will Jones
>            Priority: Major
>
> I was surprised to find you can't use standard arithmetic operators on PyArrow arrays and scalars. Instead, one must use the compute functions:
> {code:Python}
> 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
> {code}
> Is it intentional we don't support this?



--
This message was sent by Atlassian Jira
(v8.20.7#820007)