I have a data of customer mails with variables email_created_date, Ref#_current_mail, Queue, ref#_last_mail, text, previous mail date and time lapse between last and current mail. I want to check whether ref# for last mail is available in column ref#_current_mail.
If available then check queue for last mail and compare it with queue for current mail. if both queue match then print 'same' else 'different'.
looking for a solution!
variables_list 1: https://i.stack.imgur.com/WFdbM.png sample_data
I have written a function as follows:
If available then check queue for last mail and compare it with queue for current mail. if both queue match then print 'same' else 'different'.
looking for a solution!
variables_list 1: https://i.stack.imgur.com/WFdbM.png sample_data
I have written a function as follows:
def Journey_Check(text, df2=df2, Reference_List=list(copy.deepcopy(df2['Reference #']))):
df2.reset_index(drop=True,inplace = True)
text = text[0]
clean_text = list(copy.deepcopy(df2['Clean_Text']))
#clean_text = [x[0] for x in clean_text]
#for text in clean_text:
#print(text)
if text in Reference_List:
#print(clean_Text.index(text))
#print(Reference_List.index(text))
if(df2['Queue'][clean_text.index(text)]) == (df2['Queue'][Reference_List.index(text)]):
print('Same Journey')
else:
print('Different Journey')
else:
return('Clean text not in Reference list!')
update - Now I am able to execute a function but not getting required output as 'same journey' or 'different journey'. It's showing only 'Clean text not in Reference list!'.
Comments
Post a Comment