More fixes
This commit is contained in:
parent
15fa09430b
commit
6b12e21d50
54 changed files with 1665 additions and 630 deletions
|
|
@ -186,11 +186,11 @@ def _build(
|
|||
lsoa_pop = pl.scan_parquet(lsoa_population_path)
|
||||
wide = wide.join(lsoa_pop, on="lsoa21", how="left")
|
||||
wide = wide.with_columns(
|
||||
(pl.col("serious_crime_avg_yr") / pl.col("population") * 1000)
|
||||
.round(1)
|
||||
pl.when(pl.col("population") > 0)
|
||||
.then((pl.col("serious_crime_avg_yr") / pl.col("population") * 1000).round(1))
|
||||
.alias("serious_crime_per_1k"),
|
||||
(pl.col("minor_crime_avg_yr") / pl.col("population") * 1000)
|
||||
.round(1)
|
||||
pl.when(pl.col("population") > 0)
|
||||
.then((pl.col("minor_crime_avg_yr") / pl.col("population") * 1000).round(1))
|
||||
.alias("minor_crime_per_1k"),
|
||||
).drop("population")
|
||||
|
||||
|
|
|
|||
|
|
@ -37,4 +37,4 @@ def extract_zip(zip_path: Path, extract_dir: Path) -> None:
|
|||
"""Extract a ZIP archive into the given directory."""
|
||||
extract_dir.mkdir(parents=True, exist_ok=True)
|
||||
with zipfile.ZipFile(zip_path, "r") as zf:
|
||||
zf.extractall(extract_dir)
|
||||
zf.extractall(extract_dir, filter="data")
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ def fuzzy_join_on_postcode(
|
|||
right_match["_right_postcode"],
|
||||
right_match["_right_address"],
|
||||
):
|
||||
if postcode is not None:
|
||||
if address is not None and postcode is not None:
|
||||
right_by_postcode.setdefault(postcode, []).append((idx, address))
|
||||
|
||||
# Group left side by postcode
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue