Python client - KeyError: 'industry' when accessing to BEA/NIPA-T11706/A191RX-Q series
As reported by user in forum: https://forum.db.nomics.world/t/problem-retrieving-1-time-series-via-python-api/334
df = fetch_series('BEA/NIPA-T11706/A191RX-Q')
KeyError Traceback (most recent call last)
<ipython-input-9-da4c1b56e5b7> in <module>
----> 1 df = fetch_series('BEA/NIPA-T11706/A191RX-Q')
~/dev/jailbreak/dbnomics/dbnomics-python-client/dbnomics/__init__.py in fetch_series(provider_code, dataset_code, series_code, dimensions, series_ids, max_nb_series, api_base_url, editor_api_base_url, filters)
167 raise ValueError("When you use `series_ids`, you must not specifiy `provider_code` nor `dataset_code`.")
168 api_link = series_base_url + '?observations=1&series_ids={}'.format(','.join(series_ids))
--> 169 return fetch_series_by_api_link(api_link, filters=filters, max_nb_series=max_nb_series,
170 editor_api_base_url=editor_api_base_url)
171
~/dev/jailbreak/dbnomics/dbnomics-python-client/dbnomics/__init__.py in fetch_series_by_api_link(api_link, max_nb_series, editor_api_base_url, filters)
233 if 'dimensions_values_labels' in dataset_dimensions:
234 for dimension_code, dimension_label in dataset_dimensions_labels.items():
--> 235 dimension_value_code = series_dims_by_dataset_code[complete_dataset_code][series['series_code']][dimension_code]
236 flat_series[dimension_label] = dict(dataset_dimensions['dimensions_values_labels']
237 [dimension_code])[dimension_value_code]
KeyError: 'industry'
Other example:
df4 = fetch_series_by_api_link("https://api.db.nomics.world/v22/series/FED/G17_IP_MARKET_GROUPS?limit=1000&offset=0&q=&observations=1&align_periods=1&dimensions=%7B%22FREQ%22%3A%5B%22129%22%5D%2C%22SA%22%3A%5B%22SA%22%5D%7D", max_nb_series=100)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
<ipython-input-5-932bc440f0a0> in <module>
----> 1 df4 = fetch_series_by_api_link("https://api.db.nomics.world/v22/series/FED/G17_IP_MARKET_GROUPS?limit=1000&offset=0&q=&observations=1&align_periods=1&dimensions=%7B%22FREQ%22%3A%5B%22129%22%5D%2C%22SA%22%3A%5B%22SA%22%5D%7D", max_nb_series=100)
2 df4.head()
~/Dev/dbnomics/dbnomics-python-client/dbnomics/__init__.py in fetch_series_by_api_link(api_link, max_nb_series, editor_api_base_url, filters)
234 for dimension_code, dimension_label in dataset_dimensions_labels.items():
235 dimension_value_code = series_dims_by_dataset_code[complete_dataset_code][series['series_code']][dimension_code]
--> 236 flat_series[dimension_label] = dict(dataset_dimensions['dimensions_values_labels']
237 [dimension_code])[dimension_value_code]
238 flat_series_list.append(flat_series)
KeyError: 'B50002'
TODO before closing issue
-
add corresponding unit test -
answer to user
Edited by Bruno Duyé