Skip to content

REF/block the implicit cast of datetime.datetime to pa.date32() #58855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pandas/core/arrays/arrow/array.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import datetime
import functools
import operator
import re
Expand Down Expand Up @@ -427,6 +428,8 @@ def _box_pa_scalar(cls, value, pa_type: pa.DataType | None = None) -> pa.Scalar:
pa_scalar = value
elif isna(value):
pa_scalar = pa.scalar(None, type=pa_type)
elif pa_type == pa.date32() and isinstance(value, datetime.datetime):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PedroVerardo this is a nice find, but if pyarrow supports it I don't think we should do anything special in pandas to handle this. Looks like we should just open the issue upstream

raise ValueError("Cannot convert datetime to date32")
else:
# Workaround https://github.com/apache/arrow/issues/37291
if isinstance(value, Timedelta):
Expand Down
Loading