我有一本这样的字典:
{4722: "['children', 'dance', 'education','technology', 'teaching']",
3200: "['alternative energy', 'sustainability', 'technology']",
1636: "['computers', 'performance', 'simplicity', 'software', 'ice']",
1697: "['MacArthur grant', 'inequality', 'technology', 'pollution']"}
现在,我想在每一行中找到“技术”一词,并对键求和。像这里,我的总和为4722 + 3200 + 1697。
谁能帮我吗?
我应该提到我的原始数据框有2000行。
your_data = {
4722: "['children', 'dance', 'education','technology', 'teaching']",
3200: "['alternative energy', 'sustainability', 'technology']",
1636: "['computers', 'performance', 'simplicity', 'software', 'ice']",
1697: "['MacArthur grant', 'inequality', 'technology', 'pollution']"
}
sum_up = 0
for k, v in your_data.items():
if 'technology' in v:
sum_up += k
print('sum_up:', sum_up)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句