Skip to content

BUG: Assigning datetime to pa.date32() type array should raise #58420

Closed
@WillAyd

Description

@WillAyd

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd
import pyarrow as pa

pa_arr = pa.array([
    datetime.date(2024, 1, 1),
    datetime.date(2024, 1, 2),
    datetime.date(2024, 1, 3),
])
ser = pd.Series(pa_arr, dtype=pd.ArrowDtype(pa.date32()))
ser.iloc[0] =  datetime.datetime(2024, 12, 31, 12, 20, 0)

Issue Description

Assigning a datetime value to a pyarrow date array type seems to implicitly drop the time components

Expected Behavior

Should raise TypeError

Installed Versions

In [24]: pd.version
Out[24]: '3.0.0.dev0+681.g434fda08cf'

In [25]: pa.version
Out[25]: '15.0.0'

Metadata

Metadata

Labels

Arrowpyarrow functionalityBugDatetimeDatetime data dtype

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions