作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在列表中有相同格式的嵌套字典。我试图遍历每个元素并找到我们拥有 summary
值的次数如 through the API
并计算 through the API
的受让人数量.
[{'id': '101',
'type': 'log_file',
'summary': 'Escalated to Mark through the API',
'assignees': [{'id': 'xyz',
'type': 'user_reference',
'summary': 'Mark'}]},
{'id': '102',
'type': 'log_file',
'summary': 'Escalated to Kevin by SMS',
'assignees': [{'id': 'abc',
'type': 'user_reference',
'summary': 'Kevin'}]},
{'id': '103',
'type': 'log_file',
'summary': 'Escalated to Scott through the API',
'assignees': [{'id': 'pqr',
'type': 'user_reference',
'summary': 'Scott'}]}]
through the API
已返回
summary
受让人值为
Mark and Scott
因为这两个不同的人被分配了。
最佳答案
制作 Pandas 数据框:
df=pd.DataFrame(dd)
df['summary'].str.contains('through the API').sum()
df['names'] = pd.Series([df.iloc[s,3][0]['summary'] for s in np.arange(0,df.shape[0])])
关于Python - 循环遍历嵌套字典并获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61048560/
我是一名优秀的程序员,十分优秀!