0

I have a function ready to use to find the Nearest Neighbor. The issue that I have is I need to call this function based on one column condition of the data frame. The column is the ITC code which is the product code of the companies. I want the nearest neighbor to give me 10 results when first 8 digits product code matches for the companies then search in the companies when first 7 digits matches, then for first 6 digits and so on.

Some of the columns of my dataframe look like

enter image description here

4
  • Welcome to StackOverflow. Please take the time to read this post on how to provide a minimal, complete, and verifiable example and revise your question accordingly. These tips on how to ask a good question may also be useful. Feb 11, 2019 at 7:30
  • What have you tried until now? Where are coming up with a problem? Feb 11, 2019 at 7:31
  • Actually, I am new to coding, so I don't know how to exactly start to achieve this. But I have tried converting the ITC code column to string and get the digits by its index, then I want to know how to compare those with other values of ITC code.
    – Tanya
    Feb 11, 2019 at 7:36
  • Ok. Add your dataframes as code instead of image. You are actively not helping people find a solution. Please read stackoverflow.com/help/mcve . Feb 11, 2019 at 8:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.