I am trying to write a condition check for tagging Technical terms. I have used a dictionary to look up to and do a fuzzy match. My dataframe is something like this-
Word Entity Score Tag technology similarity
Stonetrust CRR 0.90 MISC xxx 90
Wilkes CRR 0.80 ORG xxx 60
linux xxx 0.70 LOC xxx 70
SILVER INC xxx 0.88 PER xxx 80
PO BOX 988 xxx 0.99 MISC xxx 70
LA 70520 xxx 0.67 PER xxx 50
02/12/2019 xxx 0.23 MISC xxx 100
I need to check for below condition and create a new column with final tags-
- if similarity score = 100 then final_tag = TECH
- if Tag = MISC and similarity score >=95 then final_tag = TECH
To do this I did wrote below code
df['new column name'] = df['column name'].apply(lambda x: 'value if condition is met' if x condition else 'value if condition is not met')
df1['Final_NER'] = df1['similarity'].apply(lambda x: 'TECH' if x == 100 else df1['NER_Tag'])
df1['Final_NER'] = df1['similarity'].apply(lambda x: 'Tech' if df1['NER_Tag'] == MISC and if x >= 95 else df1['NER_Tag'])
I am not getting correct output and getting below error-
AttributeError: 'builtin_function_or_method' object has no attribute 'get_indexer'
Aucun commentaire:
Enregistrer un commentaire