rok commented on issue #41132: URL: https://github.com/apache/arrow/issues/41132#issuecomment-2048573219
Thanks for reporting this @nikfio ! This is due to [`pc.strptime`](https://arrow.apache.org/docs/dev/python/generated/pyarrow.compute.strptime.html#pyarrow-compute-strptime) using the [C/C++ format semantics](https://man7.org/linux/man-pages/man3/strptime.3.html) for parsing instead of the Python ones. Namely it seems it's the `%f` flag that is causing this issue as this works fine: ```python >>> pc.strptime('20090101 185956', format='%Y%m%d %H%M%S', unit='ms') <pyarrow.TimestampScalar: '2009-01-01T18:59:56.000'> ``` To work around this you can try [this (cumbersome) approach] for now: ```python import pyarrow as pa import pyarrow.compute as pc ts = pa.array(["1970-01-01T00:00:59.123456789", "2000-02-29T23:23:23.999999999"], pa.string()) ts2 = pc.strptime(pc.utf8_slice_codeunits(ts, 0, 19), format="%Y-%m-%dT%H:%M:%S", unit="ns") d = pc.utf8_slice_codeunits(ts, 20, 99).cast(pa.int64()).cast(pa.duration("ns")) pc.add(ts2, d) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
