Skip to content

printing a dataframe ignores timezone information of columns containing datetime64 #9709

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
satizabal opened this issue Mar 23, 2015 · 1 comment
Labels
Timezones Timezone data dtype Usage Question

Comments

@satizabal
Copy link

I have a dataframe with a column containing dates (I do not want to use this column as the index of my dataframe). When printing the dataframe, the timezone information is lost. Directly accessing the .values shows the correct timezone.

This might be related to #6415

import pandas as pd

print "pandas version : ", pd.__version__

series = pd.to_datetime([1426374000000, 1426415697429], unit='ms').tz_localize('UTC').tz_convert('Europe/Berlin')
print '-- Printing series --'
print series
df = pd.DataFrame(series)
print '-- Printing df --'
print df
print '-- Printing df.values --'
print df.values
pandas version :  0.16.0
-- Printing series --
<class 'pandas.tseries.index.DatetimeIndex'>
[2015-03-15 00:00:00+01:00, 2015-03-15 11:34:57.429000+01:00]
Length: 2, Freq: None, Timezone: Europe/Berlin
-- Printing df --
                           0
0        2015-03-14 23:00:00
1 2015-03-15 10:34:57.429000
-- Printing df.values --
[['2015-03-15T00:00:00.000000000+0100']
 ['2015-03-15T11:34:57.429000000+0100']]
@jreback
Copy link
Contributor

jreback commented Mar 23, 2015

this will be resolved by #8260

currently the dtype of datetimes with timezones are of object dtype (and NOT datetime64[ns]
and hence there is not timezone information indicated on the column. It IS on the individual objects.

So this is a highly inefficient way to do things, but was simpler when it was implemented (quite a while ago).

@jreback jreback closed this as completed Mar 23, 2015
@jreback jreback added the Timezones Timezone data dtype label Mar 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Timezones Timezone data dtype Usage Question
Projects
None yet
Development

No branches or pull requests

2 participants