From 283abc16b008ba60b52be1670718a878914ade44 Mon Sep 17 00:00:00 2001 From: Vasiliki Panagi <75254435+vpnu@users.noreply.github.com> Date: Fri, 24 Jan 2025 11:14:03 +0000 Subject: [PATCH] Replace nan with empty string in distribution response (#55) * replace nan with empty string * remove print statement --- src/hutch_bunny/core/query_solvers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/hutch_bunny/core/query_solvers.py b/src/hutch_bunny/core/query_solvers.py index 8085432..be08c28 100644 --- a/src/hutch_bunny/core/query_solvers.py +++ b/src/hutch_bunny/core/query_solvers.py @@ -381,7 +381,8 @@ def solve_query(self) -> Tuple[str, int]: ) for _, row in concepts_df.iterrows(): df.loc[df["OMOP"] == row["concept_id"], "OMOP_DESCR"] = row["concept_name"] - + # replace NaN values with empty string + df = df.fillna('') # Convert df to tab separated string results = list(["\t".join(df.columns)]) for _, row in df.iterrows(): @@ -564,6 +565,7 @@ def solve_distribution( res_b64_bytes = base64.b64encode(res.encode("utf-8")) # bytes size = len(res_b64_bytes) / 1000 # length of file data in KB res_b64 = res_b64_bytes.decode("utf-8") # convert back to string, now base64 + result_file = File( data=res_b64, description="Result of code.distribution anaylsis",