You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "Joris Van den Bossche (Jira)" <ji...@apache.org> on 2021/02/24 13:03:00 UTC

[jira] [Commented] (ARROW-11646) [Python] Allow to create BooleanArray from a list of 0 and 1

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

Joris Van den Bossche commented on ARROW-11646:
-----------------------------------------------

[~lhoestq] Thanks for the report. I agree it would be good to enable this as well for consistency.

> [Python] Allow to create BooleanArray from a list of 0 and 1
> ------------------------------------------------------------
>
>                 Key: ARROW-11646
>                 URL: https://issues.apache.org/jira/browse/ARROW-11646
>             Project: Apache Arrow
>          Issue Type: Improvement
>          Components: Python
>    Affects Versions: 3.0.0
>            Reporter: quentin lhoest
>            Priority: Major
>
> Hi everyone !
> Currently one can create a BooleanArray using these ways:
> {code:python}
> pa.array([False, True, True, False])
> pa.array(np.array([0, 1, 1, 0]), type=pa.bool_())
> pa.array([0, 1, 1, 0]).cast(pa.bool_())
> {code}
> But creating it this way fails:
> {code:python}
> pa.array([0, 1, 1, 0], type=pa.bool_())
> {code}
> {code}
> ---------------------------------------------------------------------------
> ArrowInvalid                              Traceback (most recent call last)
> <ipython-input-2-e132766d7a68> in <module>
> ----> 1 a = pa.array([0, 1, 1, 0], type=pa.bool_())
> ~/.virtualenvs/hf-datasets/lib/python3.7/site-packages/pyarrow/array.pxi in pyarrow.lib.array()
> ~/.virtualenvs/hf-datasets/lib/python3.7/site-packages/pyarrow/array.pxi in pyarrow.lib._sequence_to_array()
> ~/.virtualenvs/hf-datasets/lib/python3.7/site-packages/pyarrow/error.pxi in pyarrow.lib.pyarrow_internal_check_status()
> ~/.virtualenvs/hf-datasets/lib/python3.7/site-packages/pyarrow/error.pxi in pyarrow.lib.check_status()
> ArrowInvalid: Could not convert 0 with type int: tried to convert to boolean
> {code}
> Thanks in advance for the help



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