The error I am receiving is : TypeError: 'NoneType' object is not subscriptable
In this Method I am trying to do string matching along two files (test&master). The master file contains correctly spelled product names, while the test file contains misspelling or simply differently spelled versions of those products. I am trying to match those together with the extractBests function to include a cutoff at a certain score. Also if I am printing earlier steps of my output, for example the fhp_new variable it still works.
I think the error is somehow caused by the fact, that some rows to not give any matches that are within the score_cutoff limit, because I don't get the error when I put the limit on say 20. So in theory those rows should just stay empty, but this causes the error I think.
This line of code is causing the error:
for x in range (1, num_match + 1):
d["Match{0}".format(x)] = [y[0] for y in aggregated_matches["Match" + str(x)]]
This is the full Code until the line of error
def StringMatch (master, testfile, num_match=3, score_cutoff=95, limit=3):
master_names = master.iloc[:,3]
test_names = testfile.iloc[:,0]
fhp_new = [process.extractBests(x, master_names, score_cutoff=score_cutoff,limit=limit) for x in test_names]
lab=" "
i=1
while i<=num_match:
lab = lab + " " + "Match" + str(i)
i = i+1
aggregated_matches = pd.DataFrame(fhp_new, columns = lab.split())
d={}
for x in range (1, num_match + 1):
d["Match{0}".format(x)] = [y[0] for y in aggregated_matches["Match" + str(x)]]
print(d)