Skip to content
This repository was archived by the owner on Apr 30, 2022. It is now read-only.

Commit fff2adc

Browse files
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
1 parent 26ad37e commit fff2adc

File tree

8 files changed

+23
-8
lines changed

8 files changed

+23
-8
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ sudo: false
22
language: python
33
python:
44
- "2.7"
5-
- "3.3"
65
- "3.4"
76
- "3.5"
87
- "3.6"

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
### 3.4.0 - 2018-07-03
2+
3+
* When returning a list of data, in a Python friendly format, convert datetime64 to datetime
4+
* Numpy no longer supports Python v3.3, thus we are removing support for it
5+
16
### 3.3.0 - 2017-12-20
27

38
* Unlock the version of requests to allow use with other modern packages

quandl/model/data_mixin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ def to_pandas(self, keep_column_indexes=[]):
1212
data = [data]
1313
if 'columns' in self.meta.keys():
1414
df = pd.DataFrame(data=data, columns=self.columns)
15-
for index, type in enumerate(self.column_types):
16-
if type == 'Date':
15+
for index, column_type in enumerate(self.column_types):
16+
if column_type == 'Date':
1717
df[self.columns[index]] = df[self.columns[index]].apply(pd.to_datetime)
1818
else:
1919
df = pd.DataFrame(data=data, columns=self.column_names)

quandl/model/merged_data_list.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .data_list import DataList
2+
import numpy as np
23

34

45
class MergedDataList(DataList):
@@ -17,7 +18,17 @@ def to_pandas(self):
1718
return self.__data_frame
1819

1920
def _initialize_raw_data(self):
20-
return self.to_numpy().tolist()
21+
numpy_results = self.to_numpy()
22+
numpy_dtype_names = numpy_results.dtype.names
23+
24+
python_compatible_dtypes = []
25+
for name in numpy_dtype_names:
26+
if numpy_results.dtype[name].str == '<M8[ns]':
27+
python_compatible_dtypes.append((str(name), np.dtype('<M8[ms]')))
28+
else:
29+
python_compatible_dtypes.append((str(name), numpy_results.dtype[name]))
30+
31+
return numpy_results.astype(python_compatible_dtypes).tolist()
2132

2233
def _column_names(self):
2334
return self.to_numpy().dtype.names

quandl/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '3.3.0'
1+
VERSION = '3.4.0'

test/test_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,6 @@ def test_build_request(self, mock):
6767
'accept': ('application/json, '
6868
'application/vnd.quandl+json;version=2015-04-09'),
6969
'request-source': 'python',
70-
'request-source-version': '3.3.0'},
70+
'request-source-version': '3.4.0'},
7171
params={'per_page': 10, 'page': 2})
7272
self.assertEqual(mock.call_args, expected)

test/test_merged_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def test_get_merged_dataset_data_to_list(self):
203203
[datetime.datetime(2015, 7, 14, 0, 0), 437.5, 3, 437.5, 437.5, 3, 3],
204204
[datetime.datetime(2015, 7, 15, 0, 0), 440.0, 2, 440.0, 440.0, 2, 3]]
205205
for index, expected_item in enumerate(expected):
206-
self.assertItemsEqual(results[index], expected_item)
206+
self.assertItemsEqual(expected_item, results[index])
207207

208208
def test_get_merged_dataset_data_is_descending_when_specified_in_params(self):
209209
data = MergedDataset(['NSE/OIL', 'WIKI/AAPL',

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# test suite on all supported python versions. To use it, "pip install tox"
44
# and then run "tox" from this directory.
55
[tox]
6-
envlist = py2.7,py3.3,py3.4,py3.5,py3.6
6+
envlist = py2.7,py3.4,py3.5,py3.6
77

88
[testenv]
99
commands =

0 commit comments

Comments
 (0)