Tonight
This commit is contained in:
parent
28323f145e
commit
94f9c0d594
76 changed files with 3238 additions and 1230 deletions
|
|
@ -1086,12 +1086,56 @@ GROCERY_RETAILER_DISPLAY_NAMES: dict[str, str] = {
|
|||
}
|
||||
|
||||
|
||||
GROCERY_FASCIA_ICON_NAMES: dict[str, str] = {
|
||||
"Aldi Local": "Aldi",
|
||||
"Asda Express": "Asda Express",
|
||||
"Asda Living": "Asda Living",
|
||||
"Asda PFS": "Asda PFS",
|
||||
"Cooltrader": "Heron Foods",
|
||||
"Cook": "COOK",
|
||||
"Eurospar": "Spar",
|
||||
"Eurospar PFS": "Spar",
|
||||
"Heron": "Heron Foods",
|
||||
"Little Waitrose": "Little Waitrose",
|
||||
"Little Waitrose Shell": "Little Waitrose",
|
||||
"Marks and Spencer": "M&S",
|
||||
"Marks and Spencer BP": "M&S Food",
|
||||
"Marks and Spencer Clothing": "M&S Clothing",
|
||||
"Marks and Spencer Food To Go": "M&S Food",
|
||||
"Marks and Spencer Food Outlet": "M&S Outlet",
|
||||
"Marks and Spencer Foodhall": "M&S Food",
|
||||
"Marks and Spencer Hospital": "M&S Hospital",
|
||||
"Marks and Spencer MSA": "M&S MSA",
|
||||
"Marks and Spencer Outlet": "M&S Outlet",
|
||||
"Marks and Spencer Simply Food": "M&S Food",
|
||||
"Marks and Spencer Travel SF": "M&S Food",
|
||||
"Morrisons Daily": "Morrisons Daily",
|
||||
"Morrisons Select": "Morrisons",
|
||||
"Sainsburys": "Sainsbury's",
|
||||
"Sainsburys Local": "Sainsbury's Local",
|
||||
"Spar PFS": "Spar",
|
||||
"Tesco Express": "Tesco Express",
|
||||
"Tesco Express Esso": "Tesco Express",
|
||||
"Tesco Extra": "Tesco Extra",
|
||||
"The Co-operative Food": "Co-op",
|
||||
"The Co-operative Food PFS": "Co-op",
|
||||
"The Food Warehouse": "The Food Warehouse",
|
||||
"Waitrose MSA": "Waitrose",
|
||||
}
|
||||
|
||||
|
||||
def normalize_grocery_retailer(retailer: str | None) -> str:
|
||||
if retailer is None:
|
||||
return ""
|
||||
return GROCERY_RETAILER_DISPLAY_NAMES.get(retailer, retailer)
|
||||
|
||||
|
||||
def normalize_grocery_icon_category(fascia: str | None, retailer: str | None) -> str:
|
||||
if fascia:
|
||||
return GROCERY_FASCIA_ICON_NAMES.get(fascia, normalize_grocery_retailer(fascia))
|
||||
return normalize_grocery_retailer(retailer)
|
||||
|
||||
|
||||
def transform_grocery_retail_points(
|
||||
grocery_df: pl.DataFrame,
|
||||
boundary_path: Path | None = None,
|
||||
|
|
@ -1133,9 +1177,15 @@ def transform_grocery_retail_points(
|
|||
pl.col("retailer")
|
||||
.map_elements(normalize_grocery_retailer, return_dtype=pl.String)
|
||||
.alias("category"),
|
||||
pl.struct(["fascia", "retailer"])
|
||||
.map_elements(
|
||||
lambda row: normalize_grocery_icon_category(row["fascia"], row["retailer"]),
|
||||
return_dtype=pl.String,
|
||||
)
|
||||
.alias("icon_category"),
|
||||
pl.lit("Groceries").alias("group"),
|
||||
pl.lit("🛒").alias("emoji"),
|
||||
).select("id", "name", "category", "group", "lat", "lng", "emoji")
|
||||
).select("id", "name", "category", "icon_category", "group", "lat", "lng", "emoji")
|
||||
|
||||
|
||||
def transform(
|
||||
|
|
@ -1189,6 +1239,7 @@ def transform(
|
|||
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("icon_category"),
|
||||
pl.col("category").replace_strict(emoji_mapping).alias("emoji"),
|
||||
)
|
||||
|
||||
|
|
@ -1203,6 +1254,7 @@ def transform(
|
|||
naptan = naptan_df.lazy().with_columns(
|
||||
pl.col("category").replace_strict(NAPTAN_EMOJIS).alias("emoji"),
|
||||
pl.lit("Public Transport").alias("group"),
|
||||
pl.col("category").alias("icon_category"),
|
||||
)
|
||||
|
||||
frames = [lf, naptan]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue