You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you have datetime data with timezone info attached, the data is stored as Timestamp objects in a object dtyped column, instead of in a ´datetime64´ column (as this cannot hold the timezone info).
But, this causes to_sql to gives this the TEXT type:
With a postgresql engine:
In [48]: times = ['201412120154', '201412110254']
....: df = pd.DataFrame()
....: df['time'] = pd.to_datetime(times, utc=True)
In [49]: df
Out[49]:
time
0 2014-12-12 01:54:00+00:00
1 2014-12-11 02:54:00+00:00
In [50]: df.dtypes
Out[50]:
time object
dtype: object
In [51]: df.time.values
Out[51]:
array([Timestamp('2014-12-12 01:54:00+0000', tz='UTC'),
Timestamp('2014-12-11 02:54:00+0000', tz='UTC')], dtype=object)
In [53]: print pd.io.sql.get_schema(df, 'test', con=engine_postgres)
CREATE TABLE test (
time TEXT
)
This is because:
In [54]: pd.lib.infer_dtype(df['time'])
Out[54]:
'datetime'
instead of datetime64, and this case is not handled at the moment.
The text was updated successfully, but these errors were encountered:
When you have datetime data with timezone info attached, the data is stored as
Timestamp
objects in aobject
dtyped column, instead of in a ´datetime64´ column (as this cannot hold the timezone info).But, this causes
to_sql
to gives this theTEXT
type:With a postgresql engine:
This is because:
instead of
datetime64
, and this case is not handled at the moment.The text was updated successfully, but these errors were encountered: