Skip to content

Instantly share code, notes, and snippets.

@lmeulen
Last active May 6, 2021 06:40
Show Gist options
  • Save lmeulen/99d35a1816edc55a55a8331a3483454d to your computer and use it in GitHub Desktop.
Save lmeulen/99d35a1816edc55a55a8331a3483454d to your computer and use it in GitHub Desktop.
traveltime_unreachables
# Unreachable? Closest other postal area and add 15 min
for index, pcode in pc.iterrows():
if math.isnan(pcode.Traveltime):
# get 'not disjoint' countries
dst=pc[pc.geometry.touches(pcode.geometry)]['Traveltime'].mean(skipna=True)
# add names of neighbors as NEIGHBORS value
if ~math.isnan(dst) and (dst > 0):
pc.at[index, "Traveltime"] = int(dst + 15)
else:
pc.at[index, "Traveltime"] = pc.Traveltime.max()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment