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

Nearest Neighbor between two dataframes #47

Open
rbhatia46 opened this issue Sep 9, 2020 · 3 comments
Open

Nearest Neighbor between two dataframes #47

rbhatia46 opened this issue Sep 9, 2020 · 3 comments

Comments

@rbhatia46
Copy link

Hi,
Thanks for the amazing work!
I have two dataframes, A has about 200 Million points and B has about 10 Million points, I want to find the nearest neighbor for every point in A from B, I want to do this preferably in Python, how can I achieve it using this library?

@hexiaoyupku
Copy link

Hi rbhatia46, have you found a solution ? I'm facing the same problem, it will be great help!
Thanks.

@rbhatia46
Copy link
Author

Hi @hexiaoyupku ,
After looking at a lot of solutions, nothing worked, try looking at Pandas UDF and write a custom UDF for your nearest neighbour use-case, Pandas UDFs are much more performant than usual Spark UDFs, because they are vectorised and use Apache Arrow for optimised conversion between Python and JVM. They should be decent in terms of performance, if you still want further optimisation, then you can write your UDF in Scala(if you are familiar with it, or if your tech stack allows it), otherwise Pandas UDFs in PySpark should be fine.

@wahyudierwin
Copy link

Hi @rbhatia46 , could you give the code which uses Pandas UDF? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants