I am trying to load the data to the dataframe so I could use it later on in recordlinkage, however I get the error:
Empty DataFrame Columns: [FirstName, LastName, CompanyName] Index: []
And I am not sure that I am doing wrong?
Code:
import pymssql
import time
import recordlinkage
import pandas.io.sql as psql
#SQL connection
conn = pymssql.connect(host='server', user='xx', password='xx', database='Test')
cursor = conn.cursor()
print(time.ctime())
sql = "select FirstName, LastName, CompanyName, ID from [Test].[dbo].[Person]with(nolock) where ID < 100"
dfA = psql.read_sql(sql, conn, index_col='ID')
print(dfA)
# Indexation step
pcl = recordlinkage.index.Block(on='FirstName')
pairs = pcl.index(dfA)
# Comparison step
compare_cl = recordlinkage.Compare()
compare_cl.exact('FirstName', 'FirstName', label='FirstName')
compare_cl.string('LastName', 'LastName', method='jarowinkler', threshold=0.85, label='LastName')
compare_cl.string('CompanyName', 'CompanyName', threshold=0.85, label='CompanyName')
features = compare_cl.compute(pairs, dfA)
# Classification step
matches = features[features.sum(axis=1) > 3]
print(len(matches))
print(matches)
This part was returning error that there is not data in DataFrame to fix that change > 3 to > 2 or >1
matches = features[features.sum(axis=1) > 3]