Skip to content

BUG: UnknownTimezoneWarning from df.to_datetime() #38928

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
nabelekt opened this issue Jan 3, 2021 · 2 comments
Closed

BUG: UnknownTimezoneWarning from df.to_datetime() #38928

nabelekt opened this issue Jan 3, 2021 · 2 comments
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@nabelekt
Copy link

nabelekt commented Jan 3, 2021

I have test.csv:

datetime
Oct 19, 2020 06:58:20 PM EDT
Oct 19, 2020 04:45:33 PM EDT

and test.py:

import pandas as pd
from datetime import datetime

input_file_path = 'test.csv'

df = pd.read_csv(input_file_path, delimiter=';')

print(df)

df['datetime'] = pd.to_datetime(df['datetime'])

print(df)

Running python test.py results in:

                       datetime
0  Oct 19, 2020 06:58:20 PM EDT
1  Oct 19, 2020 04:45:33 PM EDT
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/dateutil/parser/_parser.py:1218: UnknownTimezoneWarning: tzname EDT identified but not understood.  Pass `tzinfos` argument in order to correctly return a timezone-aware datetime.  In a future version, this will raise an exception.
  category=UnknownTimezoneWarning)
             datetime
0 2020-10-19 18:58:20
1 2020-10-19 16:45:33

The UnknownTimezoneWarning from dateutil is what I am concerned about. I don't believe there is currently a way to pass an argument to panda's to_datetime() to avoid this. Am I missing something or does this need to be addressed?

Running with pandas v1.2.0, python v3.7.3.

@nabelekt nabelekt added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels Jan 3, 2021
@nabelekt nabelekt changed the title BUG: BUG: UnknownTimezoneWarning from df.to_datetime() Jan 3, 2021
@mroeschke
Copy link
Member

mroeschke commented Jan 4, 2021

You can filter the warning in your code, but it is still relevant for pandas to raise this warning as we are using dateutil for the datetime parsing. The parsing behavior depends on the the version of dateutil you have installed.

If you know the timezone ahead of time, you can also preprocess your dates to strip these unsupported timezone conventions and use the tz_localize method.

The relevant issue on the pandas side is #18702. If you have any further question regarding this timezone format, please comment on that issue. So will close this one.

@nabelekt
Copy link
Author

nabelekt commented Jan 4, 2021

Glad to see that there is already another issue open. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

No branches or pull requests

2 participants