From 42ba3e3d25adcd9999d63552b4d1ffcea627f7b2 Mon Sep 17 00:00:00 2001 From: edwardxtg <71764756+edwardxtg@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:10:58 +0100 Subject: [PATCH] =?UTF-8?q?Update=20json=5Fdict=5Fto=5Fdataframe=20delimit?= =?UTF-8?q?er=20to=20":"=20rather=20than=20"-"=20to=20avo=E2=80=A6=20(#129?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update json_dict_to_dataframe delimiter to ":" rather than "-" to avoid issues * Add check if ":" in id * Roll back check if ":" in id --- tz/osemosys/utils/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tz/osemosys/utils/utils.py b/tz/osemosys/utils/utils.py index 1f1857c7..d2c3df1f 100644 --- a/tz/osemosys/utils/utils.py +++ b/tz/osemosys/utils/utils.py @@ -287,7 +287,7 @@ def json_dict_to_dataframe(data, prefix=""): # If data is a dictionary, iterate through its items result = pd.DataFrame() for key, value in data.items(): - new_prefix = f"{prefix}-{key}" if prefix else key + new_prefix = f"{prefix}:{key}" if prefix else key df = json_dict_to_dataframe(value, new_prefix) result = pd.concat([result, df], axis=1) if ( @@ -296,7 +296,7 @@ def json_dict_to_dataframe(data, prefix=""): result = result.T result = result.reset_index() - result = pd.concat([result["index"].str.split("-", expand=True), result[0]], axis=1) + result = pd.concat([result["index"].str.split(":", expand=True), result[0]], axis=1) return result else: return result