How to categorize (lookup) brands with spelling mistakes I have a dataset with around 4 million rows. The data has only column which contains around 50000 unique brand names (e.g. IBM, Google, Adobe, Microsoft etc.). 
I also have a lookup table which contains unique numbers associated to each of these brands. So for example, IBM is assigned number 17, Google is assigned number 22 etc. 
The task is to assign these numbers to respective brands in the dataset. In more simple words, it is vlookup in MS Excel. But, the problem I am facing here is that the brand names in the dataset have spelling mistakes! So I cannot do a simple lookup here. 
Since the data is quite large, I am willing to perform this task in R or Python. 
 A: Do you know that every name in the data has a corresponding correctly spelled name in the lookup table? In that case, you can choose the correct spelling by minimizing Levenshtein distance. Otherwise, you need to get an estimate of your number of non-matching words and decide what to do about them first.
A: Kodiologist has good advice in turns of checking some distance metric such as Levenshtein distance. Keep in mind though that in general, this problem can get extremely difficult, and you may only match a subset of your data. Issues:


*

*Different names, spelling, etc...


*

*IBM may be recorded as "IBM," "International Business Machines," or even "Intl Business Machines." (In my experience, it's rather shocking the number of different ways the same thing can be written...)

*Companies may or may not be recorded with suffixes: LLC, Corp., etc...


*Hierarchical ownership, different divisions, changing corporate structure:


*

*Nest was purchased by Google, which in turn is now a division of Alphabet Inc..

*Depending on what you want to do, you may or may not want results aggregated at the top, ownership level.

*Huge databases exist of who owns whom. They probably aren't cheap.


