[Numpy-discussion] datetime64 format parameter?

Mark Wiebe mwwiebe at gmail.com
Mon Feb 6 16:18:57 EST 2012


Hey John,

NumPy doesn't provide this, because it's already provided by the
datetime.date.strftime function in Python:

http://docs.python.org/library/datetime.html#datetime.date.strftime

One reason this format isn't supported automatically is that parsing
"MM/dd/YY" is inherently ambiguous, and the convention is different in
different parts of the world. The date "01/02/03" could be January 2nd 2003
or February 3rd, 2001, for example. The datetime constructor follows the
ISO 8601 standard for date and time formatting, which is unambiguous. This
was specified in the datetime NEP, but the 1.6 implementation unfortunately
hadn't followed that part of the spec.

Cheers,
Mark

On Mon, Feb 6, 2012 at 12:40 PM, John Salvatier
<jsalvati at u.washington.edu>wrote:

> Hello,
>
> Is there a way to specify a format for the datetime64 constructor? The
> constructor doesn't have a doc. I have dates in a file with the format
> "MM/dd/YY". datetime64 used to be able to parse these in 1.6.1 but the dev
> version throws an error.
>
> Cheers,
> John
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120206/1f00d7c4/attachment.html>


More information about the NumPy-Discussion mailing list