apache / apache/arrow

[Python] Can't convert datetime.date to pa.timestamp in pa.array

Open
#36,277 3 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.

Array does not allow this conversion, but Table does.

```
>>> import pyarrow as pa
>>> import datetime

>>> pa.table([pa.array([datetime.date(2000, 1, 1)])], schema=pa.schema([pa.field('date', pa.timestamp('s'))]))
pyarrow.Table
date: timestamp[s]
----
date: [[2000-01-01 00:00:00]]

>>> pa.array([datetime.date(2000, 1, 1)], type=pa.timestamp('s'))
Traceback (most recent call last):
File "", line 1, in
File "pyarrow/array.pxi", line 327, in pyarrow.lib.array
result = _sequence_to_array(obj, mask, size, type, pool, c_from_pandas)
File "pyarrow/array.pxi", line 39, in pyarrow.lib._sequence_to_array
chunked = GetResultValue(
File "pyarrow/error.pxi", line 144, in pyarrow.lib.pyarrow_internal_check_status
return check_status(status)
File "pyarrow/error.pxi", line 123, in pyarrow.lib.check_status
raise ArrowTypeError(message)
pyarrow.lib.ArrowTypeError: object of type cannot be converted to int
```

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