You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having a hard time figuring out the best way to construct timezone aware arrays from strings instead of Python datetime objects. Based off the pattern set by the first 3 examples above it seems like a bug that the fourth does not work?
Component(s)
Python
The text was updated successfully, but these errors were encountered:
amoeba
changed the title
PyArrow cast Unable to cast strings without Zone Offset
[Python] PyArrow cast Unable to cast strings without Zone Offset
Apr 17, 2024
Casting string to timestamp is essentially parsing of the string (strptime), and for that we currently don't allow to parse to a non-tz-aware string to a tz-aware timestamp (for that you would need to guess if the string is in local wall time or in UTC, i.e. is it a tz localize or a tz convert operation, in pandas terms).
The other examples you give are parsing a non-tz-aware string to a non-tz-aware timestamp (no ambiguity, this works fine) and casting non-tz-aware timestamp to tz-aware timestamp. This last case is also potentially ambiguous, but the casting here is a very simple zero-copy cast that essentially just changes the metadata of the timestamp type (to add a timezone), and thus essentially treats the input as UTC (and not local wall time, for which there is a specific kernel pc.assume_timezone).
And so parsing a non-tz-aware string to a tz-aware timestamp can always be done in two steps, first parsing / casting to timestamp, and then converting to tz-aware timestamp:
Describe the bug, including details regarding any error messages, version, and platform.
I'm having a hard time figuring out the best way to construct timezone aware arrays from strings instead of Python datetime objects. Based off the pattern set by the first 3 examples above it seems like a bug that the fourth does not work?
Component(s)
Python
The text was updated successfully, but these errors were encountered: