如何解决匹配词频并从熊猫中的另一个数据框中分配最大分数的类别和子类别
输入:
df = pd.DataFrame([[121,'Customer Comments xxxx ttttt','loan,mortgage,payment,refinance,rate,new,time,credit,pay,current'],[34,'Customer Comments xxxx',services'],[356,'loss,make,[908,'Customer Comments aaaaa','portal,improve,online,top,covid,web,deal,competitive,take,lost'],[4356,'Customer Comments aaassds',website,care'],[3333,'communication,sure,process,company,timely,interest,customer,know'],[33456,lot']],columns=['Loan Number','Commetns','Topic_Keywords'])
df2=pd.DataFrame([[0,current','Servicing','Refinance'],[5,'closing,survey,notary,date,title,day,close,cost','Origination','Loan closing'],[9,'service,keep,good,work,excellent,great,continue,job,company','good service'],[6,phone,call,person,email,contact,processor,communication','phone call process'],[4,helpful,officer,professional,staff,knowledgeable,hire,process','Staff/Agent behaviour'],[3,'process,easy,nothing,entire,whole,experience,everything,start','OnBoarding'],[8,'great,overall,everyone',[1,care','websites'],[2,know',[7,anything,app,change,think,thing,use,mobile','websites']],columns=['Dominant_Topic','Topic_Keywords','Cate','SubCategory'])
输出:
outdf=pd.DataFrame([[121,'Refinance',10,100],services',9,90],8,80],lost','websites','OnBoarding',lot',90]],'Category','subCategory','String_match','match_score'])
我运行主题建模并从每个评论中获取主题,我想从另一个数据框中分配类别和子类别 (使用Topic_keywords列)获取匹配的词数并迭代行并借助最大词匹配分数获得最大分数的类别和子类别。
如果有任何疑问请不要提交
解决方法
class myComponent extends Component {
constructor(props) {
super(props);
this.state = {
value: ''
};
this.updateValue = this.updateValue.bind(this);
}
updateValue(e) {
this.setState({ value: e.target.value })
}
render() {
return ( <form>
<input type="text" value={this.state.value}
onChange={this.updateValue}
defaultValue={this.state.value} />
<h4>Controlled Input:</h4> <p>{this.state.value}</p>
</form>
);
}
};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。