Add POI groups
This commit is contained in:
parent
a45495269e
commit
8e615c6aad
1 changed files with 7 additions and 0 deletions
|
|
@ -624,13 +624,20 @@ def transform(input_path: Path, naptan_path: Path | None = None) -> pl.LazyFrame
|
||||||
if missing_emojis:
|
if missing_emojis:
|
||||||
raise ValueError(f"Empty emojis for: {missing_emojis}")
|
raise ValueError(f"Empty emojis for: {missing_emojis}")
|
||||||
|
|
||||||
|
# Derive group from the first component of the raw category key, title-cased
|
||||||
|
group_mapping = {
|
||||||
|
k: k.split("/")[0].replace("_", " ").title() for k in CATEGORY_MAP
|
||||||
|
}
|
||||||
|
|
||||||
lf = lf.with_columns(
|
lf = lf.with_columns(
|
||||||
|
pl.col("category").replace_strict(group_mapping).alias("group"),
|
||||||
pl.col("category").replace_strict(name_mapping).alias("category"),
|
pl.col("category").replace_strict(name_mapping).alias("category"),
|
||||||
pl.col("category").replace_strict(emoji_mapping).alias("emoji"),
|
pl.col("category").replace_strict(emoji_mapping).alias("emoji"),
|
||||||
)
|
)
|
||||||
|
|
||||||
naptan = pl.scan_parquet(naptan_path).with_columns(
|
naptan = pl.scan_parquet(naptan_path).with_columns(
|
||||||
pl.col("category").replace_strict(NAPTAN_EMOJIS).alias("emoji"),
|
pl.col("category").replace_strict(NAPTAN_EMOJIS).alias("emoji"),
|
||||||
|
pl.lit("Public Transport").alias("group"),
|
||||||
)
|
)
|
||||||
return pl.concat([lf, naptan], how="diagonal_relaxed")
|
return pl.concat([lf, naptan], how="diagonal_relaxed")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue