0

My output will not export to excel. I am not sure what I am missing in my python script. I have installed the openpyx1 package.

The script works where I am merging two different datasets but I am not being able to access the output.

import pandas as pd
import recordlinkage

al_usa = pd.read_csv('va_reference.csv', index_col = 'id')
al_sample = pd.read_csv('state_va.csv', index_col = 'uei', low_memory=False)
al_sample = al_sample.rename(columns={'companyname': 'sample_companyname'})

indexer = recordlinkage.Index()
indexer.full()
candidates = indexer.index(al_usa, al_sample)
print(len(candidates))

compare = recordlinkage.Compare()
compare.string('companyname',
               'sample_companyname',
               threshold=0.85,
               label='business')

features = compare.compute(candidates, al_usa, al_sample)

match_counts = features.sum(axis=1).value_counts().sort_index(ascending=False)
print(match_counts)

# Save the reordered features to an Excel file
output_file = 'sorted_results.xlsx'
sorted_features.to_excel(output_file)

here is the error code: NameError: name 'sorted_features' is not define

0 Answers0