On Fri, Apr 11, 2014 at 3:56 PM, Charles R Harris <charlesr.harris@gmail.com> wrote:
Are we in a position to start looking at implementation? If so, it would be useful to have a collection of test cases, i.e., typical uses with specified results. That should also cover conversion from/(to?) datetime.datetime.
Indeed, my personal wish-list for np.datetime64 is centered much more on robust conversion to/from native date objects, including comparison.
Here are some of my particular points of frustration (apologies for the thread jacking!):- NaT should have similar behavior to NaN when used for comparisons (i.e., comparisons should always be False).
- You can't compare a datetime object to a datetime64 object.
- datetime64 objects with high precision (e.g., ns) can't compare to datetime objects.
Pandas has a very nice wrapper around datetime64 arrays that solves most of these issues, but it would be nice to get much of that functionality in core numpy,
from numpy import datetime64from datetime import datetimeprint np.datetime64('NaT') < np.datetime64('2011-01-01') # this should not to trueprint datetime(2010, 1, 1) < np.datetime64('2011-01-01') # raises exceptionprint np.datetime64('2011-01-01T00:00', 'ns') > datetime(2010, 1, 1) # another exceptionprint np.datetime64('2011-01-01T00:00') > datetime(2010, 1, 1) # finally something works!