Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp.now() throws an Error #5339

Closed
jankatins opened this issue Oct 26, 2013 · 9 comments · Fixed by #5342

Comments

@jankatins
Copy link
Contributor

commented Oct 26, 2013

Not sure if that is expected, but if it is expected it would be nice if the error message and the docsring of Timestamp.now() could be improved.

from pandas.tslib import Timestamp
Timestamp.now()

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-45-634034a47269> in <module>()
----> 1 Timestamp.now()

C:\portabel\Python27\lib\site-packages\pandas\tslib.pyd in pandas.tslib.Timestamp.__new__ (pandas\tslib.c:5167)()

TypeError: __new__() takes at most 5 positional arguments (9 given)
@cancan101

This comment has been minimized.

Copy link
Contributor

commented Oct 26, 2013

Timestamp.today() raises the same exception.

@jtratner

This comment has been minimized.

Copy link
Contributor

commented Oct 26, 2013

Trivial implementations of this would just need to add these to the Cython
Timestamp (NOT to the _timestamp class). Not sure if time.time() is
actually accurate enough.

cdef now(self):
    return Timestamp(time.time() * 1e9)

cdef today(self):
    return Timestamp(datetime.today())
@jankatins

This comment has been minimized.

Copy link
Contributor Author

commented Oct 26, 2013

It would also be nice if Timestamp.__float__() (probably simple setting __float__ = toordinal) could be implemented. That would make some special casing in https://github.com/yhat/ggplot/blob/master/ggplot/geoms/geom_density.py unnecessary.

@jtratner

This comment has been minimized.

Copy link
Contributor

commented Oct 26, 2013

@JanSchulz care to take a stab at it? I don't think Cython will let you do __float__ = toordinal like that, so you'd probably need to define as:

cdef __float__(self):
     return self.toordinal()
@jreback

This comment has been minimized.

Copy link
Contributor

commented Oct 26, 2013

@JanSchulz __float__ IMHO should raise, this is not an automatic conversion, with the ambiguity of the units, Timestamp.value is your best bet (in ns from epoch)

@cpcloud

This comment has been minimized.

Copy link
Member

commented Oct 27, 2013

Arent these class methods in datetime? Also u can call datetime.now instead
of calling time.time

On Saturday, October 26, 2013, jreback wrote:

@JanSchulz https://github.com/JanSchulz float IMHO raise, this is
not an automatic conversion, with the ambiguity of the units,
Timestamp.value is your best bet (in ns from epoch)


Reply to this email directly or view it on GitHubhttps://github.com//issues/5339#issuecomment-27154028
.

Best,
Phillip Cloud

@cancan101

This comment has been minimized.

Copy link
Contributor

commented Oct 27, 2013

@cpcloud I think @jreback's solution was to have the class methods for Timestamp call down to the class methods for datetime and then to pass the resulting datetime object to the Timestamp constructor.

@jtratner

This comment has been minimized.

Copy link
Contributor

commented Oct 27, 2013

datetime.now() has less resolution than time.time() right?

@cpcloud

This comment has been minimized.

Copy link
Member

commented Oct 27, 2013

The precision of time is system dependent. The class method now, for
example, should return the same thing as Timestamp('now').

On Sunday, October 27, 2013, Jeff Tratner wrote:

datetime.now() has less resolution than time.time() right?


Reply to this email directly or view it on GitHubhttps://github.com//issues/5339#issuecomment-27175693
.

Best,
Phillip Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.