apache / apache/arrow

[Python] mix of int and bool disallowed, but mix of int and np.bool_ allowed

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

Description

### Describe the bug, including details regarding any error messages, version, and platform.

Arrow disallows mixtures of `int` and `bool`:

```python
>>> pa.array([True, 1])
Traceback (most recent call last):
File "", line 1, in
File "pyarrow/array.pxi", line 344, in pyarrow.lib.array
File "pyarrow/array.pxi", line 42, in pyarrow.lib._sequence_to_array
File "pyarrow/error.pxi", line 154, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 91, in pyarrow.lib.check_status
pyarrow.lib.ArrowInvalid: Could not convert 1 with type int: tried to convert to boolean
>>> pa.array([1, True])
Traceback (most recent call last):
File "", line 1, in
File "pyarrow/array.pxi", line 344, in pyarrow.lib.array
File "pyarrow/array.pxi", line 42, in pyarrow.lib._sequence_to_array
File "pyarrow/error.pxi", line 154, in pyarrow.lib.pyarrow_internal_check_status
File "pyarrow/error.pxi", line 91, in pyarrow.lib.check_status
pyarrow.lib.ArrowTypeError: Expected integer, got bool
```

but allows mixtures of `int` and `np.bool_`:

```python
>>> pa.array([np.bool_(True), 1])

[
1,
1
]
>>> pa.array([1, np.bool_(True)])

[
1,
1
]
```

### 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.