mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
one place to have df_has_single_uprn
This commit is contained in:
parent
b364df89ad
commit
bec5c4f3c3
3 changed files with 2 additions and 12 deletions
|
|
@ -62,6 +62,7 @@ bash .devcontainer/backend/install-claude-skills.sh
|
|||
## Type Safety
|
||||
|
||||
All new code must pass `pyright` with zero errors under `typeCheckingMode = strict`.
|
||||
Use Optional over | None
|
||||
Annotate all function return types. Use `dict[str, Any]` for untyped external API
|
||||
payloads — never bare `dict`. Add `pandas-stubs` when introducing pandas to a module.
|
||||
|
||||
|
|
|
|||
|
|
@ -17,9 +17,8 @@ from datetime import datetime
|
|||
from backend.utils.addressMatch import (
|
||||
AddressMatch,
|
||||
get_uprn_candidates,
|
||||
df_has_single_uprn,
|
||||
score_addresses,
|
||||
)
|
||||
from backend.address2UPRN.scoring import df_has_single_uprn
|
||||
from datatypes.epc.domain.historic_epc_matching import (
|
||||
match_addresses_for_postcode,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -259,13 +259,3 @@ def get_uprn_candidates(
|
|||
out[uprn_column] = out[uprn_column].astype(str).str.replace(r"\.0$", "", regex=True)
|
||||
out["lexirank"] = out["lexiscore"].rank(method="dense", ascending=False).astype(int)
|
||||
return out.sort_values(["lexirank", "lexiscore"], ascending=[True, False])
|
||||
|
||||
|
||||
def df_has_single_uprn(df: pd.DataFrame, uprn: str, column: str = "uprn") -> bool:
|
||||
"""Returns True if all non-null UPRNs in df match the given uprn."""
|
||||
if column not in df.columns:
|
||||
return False
|
||||
uprns = df[column].dropna().astype(str).str.strip().unique()
|
||||
if len(uprns) == 0:
|
||||
return False
|
||||
return len(uprns) == 1 and uprns[0] == str(uprn)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue