[Numpy-discussion] casting from datetime64

Alex Samuel alex at alexsamuel.net
Mon May 13 00:35:58 EDT 2019


Hi,

When registering a custom cast function from datetime64 to another dtype, how can I get the units?

I am calling PyArray_RegisterCastFunc from NPY_DATETIME. Ideally, I'd like to register a separate cast function for each datetime64 units (or none at all... I don't want all units to be castable). Next best thing would be to obtain the units in the cast function and dispatch accordingly.

Is this possible? I glanced through the code, and it looks like there's a lot of hard-coded logic around datetime64, but I didn't go through it carefully. Thought I'd ask before drilling further down.

Thanks in advance,
Alex

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20190513/838c984a/attachment.html>


More information about the NumPy-Discussion mailing list