From e60ca6ee5deec26f4b17982c4a7b86acc8889a4f Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Fri, 5 Jun 2026 19:03:33 +0000 Subject: [PATCH] source of the problem in address2uprn --- backend/address2UPRN/main.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/backend/address2UPRN/main.py b/backend/address2UPRN/main.py index 02eb27dc..136f4344 100644 --- a/backend/address2UPRN/main.py +++ b/backend/address2UPRN/main.py @@ -510,6 +510,17 @@ def handler(event, context, local=False): # Create results DataFrame result_df = pd.DataFrame(results_data) + # The UPRN is integer-valued, but the no-match rows append None, so the + # mixed column lands as float64 and would serialise as "100020933699.0". + # Coerce to a nullable integer so it round-trips as "100020933699" + # (empty when missing) — the form the finaliser and the combined-results + # UI expect. `to_numeric(errors="coerce")` also folds the + # "invalid postcode" sentinel + blanks to NA (read back as missing). + if "address2uprn_uprn" in result_df.columns: + result_df["address2uprn_uprn"] = pd.to_numeric( + result_df["address2uprn_uprn"], errors="coerce" + ).astype("Int64") + # Save results to S3 try: save_results_to_s3(result_df, str(task_id), str(subtask_id))