<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Apr 11, 2014 at 3:56 PM, Charles R Harris <span dir="ltr"><<a href="mailto:charlesr.harris@gmail.com" target="_blank">charlesr.harris@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div><div class="h5"><div><span style="color:rgb(34,34,34)">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.</span></div>
</div></div></div></div></div></blockquote><div><br></div><div>Indeed, my personal wish-list for np.datetime64 is centered much more on robust conversion to/from native date objects, including comparison.</div><div><div><br>
</div><div>Here are some of my particular points of frustration (apologies for the thread jacking!):</div><div>- NaT should have similar behavior to NaN when used for comparisons (i.e., comparisons should always be False).</div>
</div><div>- You can't compare a datetime object to a datetime64 object.</div><div>- datetime64 objects with high precision (e.g., ns) can't compare to datetime objects.</div><div><br></div><div><div>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, since I don't always want to store my values in a 1-dimensional array + hash-table (the pandas Index):</div>
<div><a href="http://pandas.pydata.org/pandas-docs/stable/timeseries.html">http://pandas.pydata.org/pandas-docs/stable/timeseries.html</a><br></div></div><div><br></div><div>Here's code which reproduces all of the above:<br>
</div><div><br></div><div><div>from numpy import datetime64</div><div>from datetime import datetime</div><div><br></div><div>print np.datetime64('NaT') < np.datetime64('2011-01-01') # this should not to true</div>
<div>print datetime(2010, 1, 1) < np.datetime64('2011-01-01') # raises exception</div><div>print np.datetime64('2011-01-01T00:00', 'ns') > datetime(2010, 1, 1) # another exception</div><div>print np.datetime64('2011-01-01T00:00') > datetime(2010, 1, 1) # finally something works!</div>
</div><div><br></div></div></div></div>