-1
result = [{'label': 'butterfly', 'confidence': 0.16034618, 'topleft': {'x': 195, 'y': 23}, 'bottomright': {'x': 220, 'y': 45}}, {'label': 'butterfly', 'confidence': 0.27062774, 'topleft': {'x': 64, 'y': 58}, 'bottomright': {'x': 98, 'y': 85}}, {'label': 'butterfly', 'confidence': 0.114007816, 'topleft': {'x': 247, 'y': 191}, 'bottomright': {'x': 268, 'y': 211}}]

I want to return only the confidence value from each element.

sshashank124
  • 31,495
  • 9
  • 67
  • 76

1 Answers1

0

Try this:

my_list = [
        {
            'label': 'butterfly', 
            'confidence': 0.16034618, 
            'topleft': {'x': 195, 'y': 23}, 
            'bottomright': {'x': 220, 'y': 45}
        }, 
        {
            'label': 'butterfly', 
            'confidence': 0.27062774, 
            'topleft': {'x': 64, 'y': 58}, 
            'bottomright': {'x': 98, 'y': 85}
        }
]

confidence_values = list(
    map(
        lambda x: x['confidence'],
        my_list
    )
)

print(confidence_values)
vighnesh153
  • 4,354
  • 2
  • 13
  • 27