You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@arrow.apache.org by "quentin lhoest (Jira)" <ji...@apache.org> on 2021/02/16 17:43:00 UTC

[jira] [Updated] (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:all-tabpanel ]

quentin lhoest updated ARROW-11646:
-----------------------------------
    Description: 
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}

---------------------------------------------------------------------------
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
{noformat}

Thanks in advance for the help

  was:
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}

---------------------------------------------------------------------------
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
{noformat}



> [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}
> ---------------------------------------------------------------------------
> 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
> {noformat}
> Thanks in advance for the help



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