Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example query for all regions in tutorial notebook fails with KeyError: 'region' #122

Open
jjakubassa opened this issue Jun 1, 2023 · 1 comment

Comments

@jjakubassa
Copy link

  • Datenguide Python version: 0.4.1
  • Python version: 3.10.9
  • Operating System: MacOS 13.4 (22F66)

Description

Running this tutorial notebook locally fails (see error message below). I expected to see this table:

image

What I Did

When running the tutorial notebook from top to bottom, this example

# get data for all Bundesländer
query_all = Query.all_regions(nuts=1)
query_all.add_field('BEV001')
query_all.results().sort_values('year').head(12)

raises this error:

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[20], line 4
      2 query_all = Query.all_regions(nuts=1)
      3 query_all.add_field('BEV001')
----> 4 query_all.results().sort_values('year').head(12)

File [~/mambaforge/envs/MMDS/lib/python3.10/site-packages/datenguidepy/query_builder.py:654](https://file+.vscode-resource.vscode-cdn.net/Users/jonas/Downloads/~/mambaforge/envs/MMDS/lib/python3.10/site-packages/datenguidepy/query_builder.py:654), in Query.results(self, verbose_statistics, verbose_enums, add_units, remove_duplicates)
    647 result = QueryExecutioner(
    648     statistics_meta_data_provider=self._stat_meta_data_provider
    649 ).run_query(self)
    650 if result:
    651     # It is currently assumed that all graphql queries
    652     # that are generated internally for the Query instance
    653     # at hand yield the same meta data.
--> 654     if self._query_result_contains_undefined_region(result):
    655         raise ValueError("Queried region is invalid.")
    656     self.result_meta_data = result[0].meta_data

File [~/mambaforge/envs/MMDS/lib/python3.10/site-packages/datenguidepy/query_builder.py:669](https://file+.vscode-resource.vscode-cdn.net/Users/jonas/Downloads/~/mambaforge/envs/MMDS/lib/python3.10/site-packages/datenguidepy/query_builder.py:669), in Query._query_result_contains_undefined_region(self, result)
    666 def _query_result_contains_undefined_region(self, result):
    667     return (
    668         len(
--> 669             list(filter(lambda res: res.contains_undefined_region_result(), result))
    670         )
...
     30         )
     31     )
     32     return len(query_results_with_empty_region) > 0

KeyError: 'region'
@enryH
Copy link
Collaborator

enryH commented Jun 5, 2023

this probably means that the database changed:/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants