Improve map

This commit is contained in:
Andras Schmelczer 2026-01-25 21:39:13 +00:00
parent ced6b16140
commit a2e4c29839
10 changed files with 285 additions and 111 deletions

View file

@ -28,7 +28,8 @@ def process_postcodes() -> pl.LazyFrame:
df = df.with_columns(
pl.struct(["lat", "long"])
.map_elements(
lambda x: lat_long_to_h3(x["lat"], x["long"], res),
# Capture res by value using default argument to avoid closure bug
lambda x, res=res: lat_long_to_h3(x["lat"], x["long"], res),
return_dtype=pl.Utf8,
)
.alias(col_name)