CorrelAid / datenguide-python

MIT License
34 stars 7 forks source link

verbose_enum flag causes key error when enum is only present in one statistic out of several added #104

Closed KonradUdoHannes closed 4 years ago

KonradUdoHannes commented 4 years ago

Description

When creating a query with two or more statistics and an enum column for one of them, the verbose_enums flag of .results causes a key error.

What I Did

from datenguidepy import Query

q = Query.region('01')
stat = q.add_field('BEVSTD')
stat.add_field('GES')
stat2 = q.add_field('AI1601')
q.results(
    verbose_enums= True,
)
KonradUdoHannes commented 4 years ago

The column actually is present and gets prefixed with its corresponding statisitic as expected. So the result contains a column BEVSTD_GES. The actual problem now is, that the column ordering does not work as expected and BEVSTD_GES is between the source column and therefore not that visible. Column ordering should address this. To address the bug when mapping enum values to the verbose descriptions the functionality should properly identify BEVSTD_GES and the column to be mapped (instead of trying to map GES as it does right now.)