Skip to content

Commit

Permalink
Merge pull request #100 from CartoDB/timestamp_fix
Browse files Browse the repository at this point in the history
PostgreSQL date type is read as object type
  • Loading branch information
andy-esch authored Jun 20, 2017
2 parents f6e7fd4 + 4f19091 commit 6e7c187
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cartoframes/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ def query(self, query, table_name=None, decode_geom=False):
query. Defaults to None (no table created).
Returns:
pandas.DataFrame: DataFrame representation of query supplied.
Pandas data types are inferred from PostgreSQL data types.
In the case of PostgreSQL date types, the data type 'object' is used.
"""
self._debug_print(query=query)
if table_name:
Expand Down Expand Up @@ -473,7 +475,7 @@ def query(self, query, table_name=None, decode_geom=False):

# TODO: replace this with a function
pg2dtypes = {
'date': 'datetime64[ns]',
'date': 'object',
'number': 'float64',
'string': 'object',
'boolean': 'bool',
Expand All @@ -493,6 +495,7 @@ def query(self, query, table_name=None, decode_geom=False):
df = pd.DataFrame(
data=select_res['rows'],
columns=[k for k in fields]).astype(schema)

if 'cartodb_id' in fields:
df.set_index('cartodb_id', inplace=True)

Expand Down

0 comments on commit 6e7c187

Please sign in to comment.