Skip to content

Weird datetime string default parsing on to_datetime #16882

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

Closed
jlopezpena opened this issue Jul 11, 2017 · 1 comment
Closed

Weird datetime string default parsing on to_datetime #16882

jlopezpena opened this issue Jul 11, 2017 · 1 comment
Labels
Datetime Datetime data dtype

Comments

@jlopezpena
Copy link

jlopezpena commented Jul 11, 2017

When using default to_datetime, without format, the answers is sometimes a bit weird:

>>> import pandas as pd
>>> pd.to_datetime("2017-07-04 16-51-10")
Timestamp('2017-07-05 02:00:00')

Year and month are guessed correctly, day gets shifted by 1, and hour, minutes, seconds are completely off.

(edit) - Obviously the function works fine when passing the datetime format, it is the default guess that is weird.

@chris-b1
Copy link
Contributor

We are falling back to the dateutil parser here. It interprets the -10 as a tz offset, which I suppose makes some sense although can see why it is surprising. Closing as not pandas, xref #12585 - general dateutil compat issue.

In [20]: from dateutil.parser import parse

In [21]: parse("2017-07-04 16-51-10")
Out[21]: datetime.datetime(2017, 7, 4, 16, 0, tzinfo=tzoffset(None, -36000))

@chris-b1 chris-b1 added this to the No action milestone Jul 11, 2017
@chris-b1 chris-b1 added the Datetime Datetime data dtype label Jul 11, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype
Projects
None yet
Development

No branches or pull requests

2 participants