I am using pandas dataframes and I have data where I have customers per company. However, the company titles vary slightly but ultimately affect the data. Example:
splitCompaniesSet = map( lambda cmpnyName :
set( map( lambda name : name.split(" "), cmpnyName ) ), dataFrame['Company'] )
I think that's right.
Basically create a list of sets, each set has the company name split. Then, starting with the first element, find the set intersection of every other element with that one. For every non-empty intersection, change the name to whatever the simplest match was among all the non-empty resulting sets, i.e. take one more set intersection with all the nonempty sets and set the result to be the company name for all those non-empty matches.
Then go on to the next Company
that resulted in an empty set when intersected with the first company name. Then do this for the next Company
that was empty for the first two you tried, and so on.
There's probably a more efficient way to do it, though.