-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Timestamp("now") should match to_datetime("now") #18705
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
Comments
this needs to match what datetime doesso Timestamp.now() |
|
i would think this is obvious - now should be now; anything else is completely wrong it should not match np.datetime which does now in the current time zone which is completely wrong |
AFAICT a discussion with strong opinions occurred on this topic long before I got here.
This is confusing for a few reasons.
* Note: I now think I was wrong in the OP when I wrote that it rounds the UTC time down to midnight; it apparently rounds the local time, i.e. Getting back to the hopefully-actionable topic, a summary of the status quo:
|
we should mimic the standard library as close as possible here. most of numpy functions are wrong in that they use the local timezone for things,
is bonkers and wrong.
I think this is fine, these give back a naive stamp, its also quite convenient. [20] is completely bonkers and should just return
|
I'm quite confused by this behaviour
so that
Summing up, if I'm interested in the naive current local timestamp, I can use any one of
while My 2¢ suggestion:
|
@miccoli happy to take a PR to fix up - i don't think changing the docs is actually what we want |
OK, I'll a have a look on this: progress can be seen at master...miccoli:bugfix/GH-18705 |
Just a quick update: as of pandas-1.3.4 and numpy-1.21.3
According to numpy/numpy#10003 the current behaviour is undocumented and bound to be changed to be more consistent with stdlib Therefore in the upcoming PR I will drop all references to numpy behaviour and check only against |
According to pandas-devGH-18705 to_datetime("now") and to_datetime("today") must match semantics of Timestamp.now() and Timestamp.today().
See #17697, #18666
pd.to_datetime('now')
returns the current UTC time, whilepd.Timestamp('now')
returns the current local time.pd.to_datetime('today')
rounds the current UTC time down to midnight, whilepd.Timestamp('today')
returns the current local time (not rounded down). These should be fixed to follow a single convention.AFAICT the to_datetime behavior was designed to match the behavior of
np.datetime64('now')
andnp.datetime64('today')
. The Timestamp behavior matches the special constructorsTimestamp.now()
,Timestamp.today()
. At this point I think the least disruptive change would be to make Timestamp(...) behave like to_datetime(...).Thoughts?
The text was updated successfully, but these errors were encountered: