You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Nic Crane (Jira)" <ji...@apache.org> on 2021/06/01 08:46:00 UTC

[jira] [Updated] (ARROW-12911) [Python] sum of zero rows gives null; should give 0

     [ https://issues.apache.org/jira/browse/ARROW-12911?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Nic Crane updated ARROW-12911:
------------------------------
    Summary: [Python] sum of zero rows gives null; should give 0  (was: sum of zero rows gives null; should give 0)

> [Python] sum of zero rows gives null; should give 0
> ---------------------------------------------------
>
>                 Key: ARROW-12911
>                 URL: https://issues.apache.org/jira/browse/ARROW-12911
>             Project: Apache Arrow
>          Issue Type: Bug
>          Components: C++, Python
>    Affects Versions: 4.0.1
>            Reporter: Adam Hooper
>            Assignee: Yibo Cai
>            Priority: Minor
>
> {code}
> >>> pa.compute.sum(pa.array([], pa.int64()))
> <pyarrow.Int64Scalar: None>
> {code}
> I'd expect 0.
> I can't think of any reason for NULL, except that SQL returns NULL. But I can't figure out why SQL returns NULL. Does anybody know? Any textbook -- and https://en.wikipedia.org/wiki/Summation -- specifies 0.
> Pandas and Numpy return 0. Also, Apache Arrow c_glib implementation returns 0 -- and even tests for it: https://github.com/apache/arrow/blob/master/c_glib/test/test-int8-array.rb#L60
> Workaround is to replace all NULLs with 0 after running the computation.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)