apache / apache/arrow

[Python] Can't convert object-dtyped NumPy arrays containing np.datetime64 objects to Arrow

Open
#40,580 1 comment 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.

```python
>>> pa.array(np.array([np.datetime64('2024-01-01')])) # works

[
2024-01-01
]
>>> pa.array(np.array([np.timedelta64(1, 'ns')], dtype=object)) # works

[
1
]
>>> pa.array(np.array([np.datetime64('2024-01-01')], dtype=object)) # fails
Traceback (most recent call last):
File "", line 1, in
File "pyarrow/array.pxi", line 340, in pyarrow.lib.array
File "pyarrow/array.pxi", line 86, in pyarrow.lib._ndarray_to_array
File "pyarrow/types.pxi", line 88, in pyarrow.lib._datatype_to_pep3118
TypeError: int() argument must be a string, a bytes-like object or a real number, not 'datetime.date'
```

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