Created
March 27, 2017 10:19
-
-
Save yjw868/7f60994b1029e24f2919dd29c6c86a04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import pandas as pd | |
import numpy as np | |
from fuzzywuzzy import process | |
infileName = 'SF Account Names.csv' | |
sfData = pd.read_csv(infileName, header=0) | |
# print (sfData.keys()) | |
# print(sfData.head()) | |
Name = sfData["Account Name"] | |
def find_app_name(name): | |
#### set score_cutoff =88 for Magnus ### | |
try: | |
app_name = process.extract(name["Account Name"], choices=Name) | |
result = [name[0] for name in app_name if 88 <= name[1] <100 ] | |
return "".join(str(item) for item in result) | |
# return result | |
except: | |
pass | |
return np.nan | |
sfData["Suggested Name"] =np.nan | |
sfData["Suggested Name"] = sfData.apply(find_app_name, axis=1) | |
# Name["Match Score"] = Name.apply(find_app_name_score, axis=1) | |
# Name["Match Position"] = Name.apply(find_app_name_position, axis=1) | |
# print (Name["Suggested name"].head()) | |
writer = pd.ExcelWriter("SF Account Names Output.xlsx") | |
#sfData.to_excel(writer, 'SF Account Name') | |
# sfData[sfData["Suggested name"].notnull()].to_excel(writer, 'SF Account Name') | |
#sfData[pd.notnull(sfData["Suggested name"])].to_excel(writer,'SF Account Name') | |
sf_output = sfData[sfData['Suggested Name'].str.len() > 1] | |
sf_output.to_excel(writer,'SF Account Name') | |
writer.save() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment