コード例 #1
0
 def data(self, **options):
     # handle_not_found_error if set to True will add an empty DataFrame
     # for a non-existent dataset instead of raising an error
     handle_not_found_error = options.pop('handle_not_found_error', False)
     handle_column_not_found = options.pop('handle_column_not_found', False)
     # default order to ascending, and respect whatever user passes in
     params = {
         'database_code': self.database_code,
         'dataset_code': self.dataset_code,
         'order': 'asc'
     }
     updated_options = Util.merge_options('params', params, **options)
     try:
         return Data.all(**updated_options)
     except NotFoundError:
         if handle_not_found_error:
             return DataList(
                 Data, [],
                 {'column_names': [six.u('None'),
                                   six.u('Not Found')]})
         raise
     except ColumnNotFound:
         if handle_column_not_found:
             return DataList(
                 Data, [],
                 {'column_names': [six.u('None'),
                                   six.u('Not Found')]})
         raise
コード例 #2
0
ファイル: test_util.py プロジェクト: syedpeer/quandl-python
 def test_merge_options_when_key_doesnt_exist_in_options(self):
     params = {'foo': 'bar', 'foo2': 'bar2'}
     options = {'params': {'foo3': 'bar3'}}
     merged = Util.merge_options('params', params, **options)
     self.assertDictEqual(
         merged, {'params': {'foo': 'bar',
                             'foo2': 'bar2', 'foo3': 'bar3'}})
コード例 #3
0
ファイル: test_util.py プロジェクト: quandl/quandl-python
 def test_merge_options_when_key_doesnt_exist_in_options(self):
     params = {'foo': 'bar', 'foo2': 'bar2'}
     options = {'params': {'foo3': 'bar3'}}
     merged = Util.merge_options('params', params, **options)
     self.assertDictEqual(
         merged, {'params': {'foo': 'bar',
                             'foo2': 'bar2', 'foo3': 'bar3'}})
コード例 #4
0
 def _get_dataset_data(self, dataset, **options):
     updated_options = options
     # if we have only one column index, let the api
     # handle the column filtering since the api supports this
     if len(dataset.requested_column_indexes) == 1:
         params = {'column_index': dataset.requested_column_indexes[0]}
         # only change the options per request
         updated_options = options.copy()
         updated_options = Util.merge_options('params', params, **updated_options)
     return dataset.data(**updated_options)
コード例 #5
0
 def _get_dataset_data(self, dataset, **options):
     updated_options = options
     # if we have only one column index, let the api
     # handle the column filtering since the api supports this
     if len(dataset.requested_column_indexes) == 1:
         params = {'column_index': dataset.requested_column_indexes[0]}
         # only change the options per request
         updated_options = options.copy()
         updated_options = Util.merge_options('params', params,
                                              **updated_options)
     return dataset.data(**updated_options)
コード例 #6
0
    def __get_raw_data__(self):
        if self._raw_data:
            return self._raw_data

        cls = self.__class__
        params = {'id': str(self.code)}
        options = Util.merge_options('params', params, **self.options)

        path = Util.constructed_path(cls.get_path(), options['params'])

        r = Connection.request('get', path, **options)
        response_data = r.json()
        Util.convert_to_dates(response_data)
        self._raw_data = response_data[singularize(cls.lookup_key())]
        return self._raw_data
コード例 #7
0
ファイル: dataset.py プロジェクト: DanielCJLee/quandl-python
 def data(self, **options):
     # handle_not_found_error if set to True will add an empty DataFrame
     # for a non-existent dataset instead of raising an error
     handle_not_found_error = options.pop('handle_not_found_error', False)
     handle_column_not_found = options.pop('handle_column_not_found', False)
     # default order to ascending, and respect whatever user passes in
     params = {
         'database_code': self.database_code,
         'dataset_code': self.dataset_code,
         'order': 'asc'
     }
     updated_options = Util.merge_options('params', params, **options)
     try:
         return Data.all(**updated_options)
     except NotFoundError:
         if handle_not_found_error:
             return DataList(Data, [], {'column_names': [six.u('None'), six.u('Not Found')]})
         raise
     except ColumnNotFound:
         if handle_column_not_found:
             return DataList(Data, [], {'column_names': [six.u('None'), six.u('Not Found')]})
         raise
コード例 #8
0
 def datasets(self, **options):
     params = {'database_code': self.code, 'query': '', 'page': 1}
     options = Util.merge_options('params', params, **options)
     return quandl.model.dataset.Dataset.all(**options)
コード例 #9
0
ファイル: database.py プロジェクト: DanielCJLee/quandl-python
 def datasets(self, **options):
     params = {'database_code': self.code, 'query': '', 'page': 1}
     options = Util.merge_options('params', params, **options)
     return quandl.model.dataset.Dataset.all(**options)