[Numpy-discussion] Dates and times and Datetime64 (again)

Sankarshan Mudkavi smudkavi at uwaterloo.ca
Sat Apr 19 00:17:19 EDT 2014


I think we'll be ready to start implementation once I get the conversion to datetime.datetime on the proposal with some decent examples. It would also be great to have opinions on what test cases should be used, so please speak up if you feel you have anything to say about that.

Cheers,
Sankarshan

On Apr 14, 2014, at 2:59 PM, Chris Barker <chris.barker at noaa.gov> wrote:

> On Fri, Apr 11, 2014 at 4:58 PM, Stephan Hoyer <shoyer at gmail.com> wrote:
> On Fri, Apr 11, 2014 at 3:56 PM, Charles R Harris <charlesr.harris at 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.
> 
> yup -- tests are always good! 
> 
> Indeed, my personal wish-list for np.datetime64 is centered much more on robust conversion to/from native date objects, including comparison.
> 
> A good use case. 
>  
> 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).
> 
> make sense.
>  
> - You can't compare a datetime object to a datetime64 object.
> 
> that would be nice to have.
>  
> - datetime64 objects with high precision (e.g., ns) can't compare to datetime objects.
> 
> That's a problem, but how do you think it should be handled? My thought is that it should round to microseconds, and then compare -- kind of like comparing float32 and float64...
>  
> 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,
> 
> yes -- it would -- but learning from pandas is certainly a good idea.
> 
> from numpy import datetime64
> from datetime import datetime
> 
> print np.datetime64('NaT') < np.datetime64('2011-01-01') # this should not to true
> print datetime(2010, 1, 1) < np.datetime64('2011-01-01') # raises exception
> print np.datetime64('2011-01-01T00:00', 'ns') > datetime(2010, 1, 1) # another exception
> print np.datetime64('2011-01-01T00:00') > datetime(2010, 1, 1) # finally something works!
> 
> 
> now to get them into proper unit tests....
> 
> -CHB
>  
> 
> -- 
> 
> Christopher Barker, Ph.D.
> Oceanographer
> 
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
> 
> Chris.Barker at noaa.gov
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

-- 
Sankarshan Mudkavi
Undergraduate in Physics, University of Waterloo
www.smudkavi.com






-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140419/bdc29794/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 496 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140419/bdc29794/attachment.sig>


More information about the NumPy-Discussion mailing list