Unexpected results with Timestamp constructor, datetime-like signature

32 views
Skip to first unread message

Antonio Piccolboni

unread,
Aug 4, 2017, 7:25:25 AM8/4/17
to PyData
How does one explain this (color added for emphasis)

In [7]: sys.version

Out[7]: '3.5.2 (default, Sep 28 2016, 18:06:29) \n[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)]'


In [98]: import pandas as pd


In [99]: pd.__version__

Out[99]: '0.20.3'


In [100]: pd.Timestamp(year = 2017,month=3,day = 15,hour = 0,minute = 0, second 

     ...:  = 0, tzinfo=pytz.timezone("US/Central"))

Out[100]: Timestamp('2017-03-15 00:51:00-0500', tz='US/Central')


In [101]: pd.Timestamp(year = 2017,month=3,day = 15,hour = 0,minute = 0, second 

     ...:  = 0, tzinfo=pytz.timezone("US/Eastern"))

Out[101]: Timestamp('2017-03-15 00:56:00-0400', tz='US/Eastern')


In [102]: pd.Timestamp(year = 2017,month=3,day = 15,hour = 0,minute = 0, second 

     ...:  = 0, tzinfo=pytz.timezone("US/Mountain"))

Out[102]: Timestamp('2017-03-15 01:00:00-0600', tz='US/Mountain')


If I specify 0 minutes, why does it become 53 or 56 depending on time zone? And what about the hour change in the last example? Thanks

Antonio Piccolboni

unread,
Aug 4, 2017, 11:46:20 PM8/4/17
to PyData
May be related to this.

Antonio Piccolboni

unread,
Aug 4, 2017, 11:58:55 PM8/4/17
to PyData
It probably is a bug inherited from datetime. 

Joris Van den Bossche

unread,
Aug 5, 2017, 4:16:38 AM8/5/17
to PyData
That is probably indeed the reason.

You can easily prevent this by doing the following:

pd.Timestamp(year = 2017,month=3,day = 15,hour = 0,minute = 0, second = 0).tz_localize("US/Central")



Op 5 aug. 2017 5:58 a.m. schreef "Antonio Piccolboni" <picc...@gmail.com>:

--
You received this message because you are subscribed to the Google Groups "PyData" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pydata+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Antonio Piccolboni

unread,
Aug 5, 2017, 2:43:04 PM8/5/17
to PyData
Thanks, and there are workarounds out there for datetime as well, but why leave the breakage in place? If it were me, fix or remove the feature. Can't wrap my mind around leaving it this way, letting people find it the hard way again and again. The same applies to pandas or datetime. 

To unsubscribe from this group and stop receiving emails from it, send an email to pydata+un...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "PyData" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pydata/1u8-nx4y4dk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pydata+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages