Skip to content

Datatime stored in DataFrame loses tz info and it goes to hour:minute #14148

Closed
@leagto

Description

@leagto
#With this code:
#-----------------------------
from datetime import datetime
import pytz
from pandas import DataFrame

original_date = datetime(2016, 9, 2, 0, 0, 0, 0, pytz.timezone('America/Manaus'))
dataframe = DataFrame(columns = ['stored_date'])
dataframe.loc['A'] = [original_date]

print("I expect it shows '2016-09-02T00:00:00-04:00', but it shows '2016-09-02 04:00:00'...")
print("original_date:            " + original_date.isoformat())
print("stored_date in dataframe: " + str(dataframe.loc['A', 'stored_date']))
#-----------------------------
#I get this output:
#-----------------------------
I expect it shows '2016-09-02T00:00:00-04:00', but it shows '2016-09-02 04:00:00'...
original_date:            2016-09-02T00:00:00-04:00
stored_date in dataframe: 2016-09-02 04:00:00
#-----------------------------
#Output from pd.show_versions()
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.7.1-1-ARCH
machine: x86_64
processor: 
byteorder: little
LC_ALL: None
LANG: pt_BR.utf8

pandas: 0.18.1
nose: None
pip: 8.1.2
setuptools: 26.0.0
Cython: 0.24.1
numpy: 1.11.1
scipy: 0.18.0
statsmodels: None
xarray: None
IPython: None
sphinx: None
patsy: None
dateutil: 2.5.3
pytz: 2016.6.1
blosc: None
bottleneck: 1.1.0
tables: 3.2.3.1
numexpr: 2.6.1
matplotlib: 1.5.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: 1.0.14
pymysql: None
psycopg2: None
jinja2: 2.8
boto: None
pandas_datareader: 0.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDuplicate ReportDuplicate issue or pull requestIndexingRelated to indexing on series/frames, not to indexes themselvesTimezonesTimezone data dtype

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions