-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: to_datetime ignores utc=True when arg is Series #6415
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 is not a feature, but a limitation of the current implementation. The difference is that in the first case the result is a DatetimeIndex and in the second and third case the result is a Series with a column with datetime64 values. But, maybe we should trigger a warning that |
I don't see how the status of trueorfalse = False
data = ['20100102 121314', '20100102 121315']
print (pd.to_datetime(data, format='%Y%m%d %H%M%S',
utc=True,box=trueorfalse)[0]).__repr__()
print (pd.to_datetime(pd.Series(data), format='%Y%m%d %H%M%S',
utc=True,box=trueorfalse)[0]).__repr__()
print (pd.to_datetime(pd.TimeSeries(data), format='%Y%m%d %H%M%S',
utc=True,box=trueorfalse)[0]).__repr__() gives numpy.datetime64('2010-01-02T04:13:14.000000000-0800')
Timestamp('2010-01-02 12:13:14', tz=None)
Timestamp('2010-01-02 12:13:14', tz=None) and as |
Note, the output you give here, for all three cases, the timezone info is lost (the fact that it is UTC). Numpy datetime64s are just always printed in your local timezone (a quirk in numpy, that's why you see a timezone). With
|
What I want to say is: |
I think maybe should remove Also can coerce the resultant series/index to a timezone (and raise if the read in has a tz). #6398 related as it fixes this for Series/index coercions @michaelaye want to submit a PR for this? |
@jreback Do you mean something like:
I would like that I think. |
yes |
As a side-note, a similar problem appears if you pass a single |
bump on this, just caused me a whole bunch of trouble 😞 |
In any case, what I said above:
is no longer the case. Series now supports tz aware data, so there is no reason to ignore |
Modify test case Comment about test edit, move conversion logic to convert_listlike Add new section in whatsnew and update test
Modify test case Comment about test edit, move conversion logic to convert_listlike Add new section in whatsnew and update test Alter SQL tests
Modify test case Comment about test edit, move conversion logic to convert_listlike Add new section in whatsnew and update test Alter SQL tests Modify whatsnew and make new wrapper function to handle UTC conversion Simiplified whatsnew and reverted arg renaming
Modify test case Comment about test edit, move conversion logic to convert_listlike Add new section in whatsnew and update test Alter SQL tests Modify whatsnew and make new wrapper function to handle UTC conversion Simiplified whatsnew and reverted arg renaming
Is this a bug or a feature that I don't understand:
results in
Using version '0.13.1'
Other example in #15760
The text was updated successfully, but these errors were encountered: