From fff2adc568fbfa3ff1b8f42b7ebbfe8043e674ba Mon Sep 17 00:00:00 2001 From: ericvautour-quandl <33837653+ericvautour-quandl@users.noreply.github.com> Date: Tue, 3 Jul 2018 11:20:00 -0400 Subject: [PATCH] Fixing date types (#110) * Fixing date types * CP-6050: Extra space * CP-6050: Testing * CP-6050: conditional with some debug * CP-6050: More testing * CP-6050: Try to figure out why order is not correct * CP-6050: Try to figure out why order is not correct * CP-6050: Try to figure out why order is not correct * CP-6050: Trying to fix order * CP-6050: Try with objects * CP-6050: Try with string * CP-6050: Cleaned up code * CP-6050: Numpy no longer supports Python v3.3 * CP-6050: Removed py3.3 from tests, bumbed version in tests * CP-6050: Bumped minor version --- .travis.yml | 1 - CHANGELOG.md | 5 +++++ quandl/model/data_mixin.py | 4 ++-- quandl/model/merged_data_list.py | 13 ++++++++++++- quandl/version.py | 2 +- test/test_connection.py | 2 +- test/test_merged_dataset.py | 2 +- tox.ini | 2 +- 8 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 72e9a39..75dc502 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ sudo: false language: python python: - "2.7" - - "3.3" - "3.4" - "3.5" - "3.6" diff --git a/CHANGELOG.md b/CHANGELOG.md index dacef2d..aa47fad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### 3.4.0 - 2018-07-03 + +* When returning a list of data, in a Python friendly format, convert datetime64 to datetime +* Numpy no longer supports Python v3.3, thus we are removing support for it + ### 3.3.0 - 2017-12-20 * Unlock the version of requests to allow use with other modern packages diff --git a/quandl/model/data_mixin.py b/quandl/model/data_mixin.py index 8ad92b2..ec6ccd9 100644 --- a/quandl/model/data_mixin.py +++ b/quandl/model/data_mixin.py @@ -12,8 +12,8 @@ def to_pandas(self, keep_column_indexes=[]): data = [data] if 'columns' in self.meta.keys(): df = pd.DataFrame(data=data, columns=self.columns) - for index, type in enumerate(self.column_types): - if type == 'Date': + for index, column_type in enumerate(self.column_types): + if column_type == 'Date': df[self.columns[index]] = df[self.columns[index]].apply(pd.to_datetime) else: df = pd.DataFrame(data=data, columns=self.column_names) diff --git a/quandl/model/merged_data_list.py b/quandl/model/merged_data_list.py index 45bfa38..772a515 100644 --- a/quandl/model/merged_data_list.py +++ b/quandl/model/merged_data_list.py @@ -1,4 +1,5 @@ from .data_list import DataList +import numpy as np class MergedDataList(DataList): @@ -17,7 +18,17 @@ def to_pandas(self): return self.__data_frame def _initialize_raw_data(self): - return self.to_numpy().tolist() + numpy_results = self.to_numpy() + numpy_dtype_names = numpy_results.dtype.names + + python_compatible_dtypes = [] + for name in numpy_dtype_names: + if numpy_results.dtype[name].str == '