From f5ee18443a517e8923d55643743459f9b78a34e6 Mon Sep 17 00:00:00 2001 From: Reynold Mok <34395415+reyery@users.noreply.github.com> Date: Wed, 17 Jan 2024 11:40:57 +0100 Subject: [PATCH] Prevent labels from being encoded as NaN in JSON --- cea/interfaces/dashboard/api/inputs.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cea/interfaces/dashboard/api/inputs.py b/cea/interfaces/dashboard/api/inputs.py index fe83780ae1..a0f8735a87 100644 --- a/cea/interfaces/dashboard/api/inputs.py +++ b/cea/interfaces/dashboard/api/inputs.py @@ -471,6 +471,10 @@ def get_choices(choice_properties, path): out.append({'value': choice_properties['none_value'], 'label': ''}) for choice in choices: label = df.loc[df[lookup['column']] == choice, 'Description'].values[0] if 'Description' in df.columns else '' + + # Prevent labels to be encoded as NaN in JSON + if str(label) == 'nan': + label = 'none' out.append({'value': choice, 'label': label}) return out