首页 > 解决方案 > 如何使用 python 只选择我需要的列

问题描述

ml = MonkeyLearn('2d14ec2555abc7f9e2aefee982e212d9091e310a')
data = ['I am excellent']
result = ml.classifiers.classify(model_id, data)
t = result.body[0]
print(t)

{'text': 'Good', 'external_id': None, 'error': False, 'classifications': [{'tag_name': 'Positive', 'tag_id': 122921383, 'confidence': 0.983}]} 

我在数组数组中有一个列表,我怎样才能从这个数据中只删除“分类”列,这个数据在数组中,我只想要所需的输出:

Classification : Tag_name : Positive 
                 Confidence : 0.983

标签: pythonarraysmachine-learningdata-science

解决方案


您可以使用此代码 -

t = {'text': 'Good', 'external_id': None, 'error': False, 'classifications': [{'tag_name': 'Positive', 'tag_id': 122921383, 'confidence': 0.983}]}
classifications = t['classifications']

推荐阅读