Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add default postcode comparison function #215

Closed
samnlindsay opened this issue Oct 12, 2021 · 7 comments
Closed

Add default postcode comparison function #215

samnlindsay opened this issue Oct 12, 2021 · 7 comments
Assignees

Comments

@samnlindsay
Copy link
Contributor

image

Generate a case expression with 3-5 levels:

CASE 
WHEN {full_match} THEN 4
WHEN {sector_match} THEN 3
WHEN {district_match} THEN 2
WHEN {area_match} THEN 1
ELSE 0 
END
@mamonu
Copy link
Contributor

mamonu commented Oct 26, 2021

would something like this work or does this need to be fully in SQL format?

def PCmatch(pc_l, pc_r):
    count = 0
    while count < len(pc_l):
        if pc_l[count] == pc_r[count]:
            count += 1
        else:
            break
    return count

@RobinL
Copy link
Member

RobinL commented Nov 11, 2021

Yeah, needs to be in the form of a SQL case expression

@mamonu
Copy link
Contributor

mamonu commented Nov 11, 2021

have a look on Slack for a ScalaUDF solution. Or is there an easier way and I am overcomplicating things?

@pbhj
Copy link

pbhj commented Sep 5, 2022

Is that too naive? Wouldn't it be better to convert to a more general geographic indicator (rather than a postal area), like lat/lon, and then compare? With this sort of comparison you might have moved one street but have an entirely different postcode?

There must be a lot of solutions to this already with UK gov codebases.

@RobinL
Copy link
Member

RobinL commented Sep 5, 2022

We have support for distance as the crow flies using lat and long input columns (not yet in the pypi version, will land in the next release):

def distance_in_km_level(

It can just sometimes be a bit of a faff to join on the geolocation to the input data, so this would provide a quick and dirty solution that would get 80% of the way there

@RossKen
Copy link
Contributor

RossKen commented Apr 14, 2023

Could build ontop of #1190

@RossKen
Copy link
Contributor

RossKen commented May 21, 2023

Closed by #1230

@RossKen RossKen closed this as completed May 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants