Good stuff
This commit is contained in:
parent
9da2db707f
commit
8032011708
32 changed files with 1052 additions and 374 deletions
|
|
@ -8,37 +8,10 @@ from pipeline.utils.postcode_mapping import build_postcode_mapping
|
|||
MIN_FLOOR_AREA_M2 = 10
|
||||
|
||||
|
||||
def _join_journey_times(
|
||||
wide: pl.LazyFrame,
|
||||
journey_times_path: Path,
|
||||
destination_name: str,
|
||||
) -> pl.LazyFrame:
|
||||
"""Join journey times for a single destination, renaming columns appropriately."""
|
||||
journey_times = (
|
||||
pl.scan_parquet(journey_times_path)
|
||||
.select(
|
||||
"postcode",
|
||||
pl.col("public_transport_quick_minutes").alias(
|
||||
f"Public transport to {destination_name} (mins)"
|
||||
),
|
||||
pl.col("cycling_minutes").alias(f"Cycling to {destination_name} (mins)"),
|
||||
)
|
||||
.sort(f"Public transport to {destination_name} (mins)", nulls_last=True)
|
||||
.group_by("postcode")
|
||||
.first()
|
||||
)
|
||||
return wide.join(journey_times, on="postcode", how="left")
|
||||
|
||||
|
||||
_AREA_COLUMNS = [
|
||||
"Postcode",
|
||||
"lat",
|
||||
"lon",
|
||||
# Transport
|
||||
"Public transport to Bank (mins)",
|
||||
"Cycling to Bank (mins)",
|
||||
"Public transport to Fitzrovia (mins)",
|
||||
"Cycling to Fitzrovia (mins)",
|
||||
# Deprivation
|
||||
"Income Score (rate)",
|
||||
"Employment Score (rate)",
|
||||
|
|
@ -97,8 +70,6 @@ def _build(
|
|||
arcgis_path: Path,
|
||||
iod_path: Path,
|
||||
poi_proximity_path: Path,
|
||||
journey_times_bank_path: Path,
|
||||
journey_times_fitzrovia_path: Path,
|
||||
ethnicity_path: Path,
|
||||
crime_path: Path,
|
||||
noise_path: Path,
|
||||
|
|
@ -138,9 +109,6 @@ def _build(
|
|||
)
|
||||
wide = wide.join(arcgis, on="postcode", how="left")
|
||||
|
||||
wide = _join_journey_times(wide, journey_times_bank_path, "Bank")
|
||||
wide = _join_journey_times(wide, journey_times_fitzrovia_path, "Fitzrovia")
|
||||
|
||||
iod = pl.scan_parquet(iod_path)
|
||||
wide = wide.join(iod, left_on="lsoa21", right_on="LSOA code (2021)", how="left")
|
||||
|
||||
|
|
@ -382,18 +350,6 @@ def main():
|
|||
type=Path,
|
||||
help="POI proximity counts parquet file (optional)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--journey-times-bank",
|
||||
type=Path,
|
||||
default=None,
|
||||
help="Journey times to Bank parquet file",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--journey-times-fitzrovia",
|
||||
type=Path,
|
||||
default=None,
|
||||
help="Journey times to Fitzrovia parquet file",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ethnicity",
|
||||
type=Path,
|
||||
|
|
@ -446,8 +402,6 @@ def main():
|
|||
arcgis_path=args.arcgis,
|
||||
iod_path=args.iod,
|
||||
poi_proximity_path=args.poi_proximity,
|
||||
journey_times_bank_path=args.journey_times_bank,
|
||||
journey_times_fitzrovia_path=args.journey_times_fitzrovia,
|
||||
ethnicity_path=args.ethnicity,
|
||||
crime_path=args.crime,
|
||||
noise_path=args.noise,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue