熊猫-迭代数据框并更新每一行

我正在尝试迭代数据帧并更新每一行,但它没有累加

final_database

                          Subject       Keyword Count  
0  Mobile_Application_Developer      android      2  
1  Mobile_Application_Developer          sql      1  
2  Mobile_Application_Developer         java      1  
0  Mobile_Application_Developer           N/A     0  
0  Mobile_Application_Developer          sql      3  
0  Mobile_Application_Developer          sql      2  
1  Mobile_Application_Developer         java      4  
2  Mobile_Application_Developer  engineering      2  
3  Mobile_Application_Developer   javascript      1  
0  Mobile_Application_Developer           N/A     0  
0  Mobile_Application_Developer           N/A     0  
0  Mobile_Application_Developer  engineering      1  
0  Mobile_Application_Developer           N/A     0  
0  Mobile_Application_Developer     building      1  
0  Mobile_Application_Developer  engineering      2  
0  Mobile_Application_Developer           N/A     0  
0  Mobile_Application_Developer  engineering      1  
0  Mobile_Application_Developer           N/A     0  

skill= "java:4,sql:3,oracle:2,json:4"
keyword_list = re.split(',', skill)
skill_list = []
total_score = 0

for x in range(len(keyword_list)):
    lang = re.split(':', keyword_list[x]) 

    skill_list.append(lang[0])
    total_score = total_score + int(lang[1]) 

for index, row in final_database.iterrows():

    for x in range(len(keyword_list)):
        lang = re.split(':', keyword_list[x]) 

        if row['Keyword'].strip() in skill_list:
            final_database.set_value(index,'Score',lang[1])

更新了final_database

                          Subject       Keyword Count Score  
0  Mobile_Application_Developer      android      2     4  
1  Mobile_Application_Developer          sql      1     4  
2  Mobile_Application_Developer         java      1     4  
0  Mobile_Application_Developer           N/A     0     4  
0  Mobile_Application_Developer          sql      3     4  
0  Mobile_Application_Developer          sql      2     4  
1  Mobile_Application_Developer         java      4     4  
2  Mobile_Application_Developer  engineering      2     4  
3  Mobile_Application_Developer   javascript      1   NaN  
0  Mobile_Application_Developer           N/A     0     4  
0  Mobile_Application_Developer           N/A     0     4  
0  Mobile_Application_Developer  engineering      1     4  
0  Mobile_Application_Developer           N/A     0     4  
0  Mobile_Application_Developer     building      1     4  
0  Mobile_Application_Developer  engineering      2     4  
0  Mobile_Application_Developer           N/A     0     4  
0  Mobile_Application_Developer  engineering      1     4  
0  Mobile_Application_Developer           N/A     0     4  

请指教。谢谢。

评论