0
n = numpy.array([(0, {'lat': 47.8634123, 'lon': 11.9994587, 'id': 0, 'label': u'271382207'}), 
                 (1, {'lat': 47.8599343, 'lon': 11.9930076, 'id': 1, 'label': u'269321789'}), 
                 (2, {'lat': 47.8601615, 'lon': 11.9933169, 'id': 2, 'label': u'269321788'})])

I want to extract all lat,lon tuples as new numpy array. How's that possible?

1 Answer 1

3

You can do it with a list comprehension:

numpy.array([(e[1]['lat'], e[1]['lon']) for e in n])

This is a basic Python construct that all developers should know about. I suggest you read an introductory book or take a course on Python.

Sign up to request clarification or add additional context in comments.

1 Comment

@user2772305 You should mark this answer as the correct one if it helped you (e.g. by clicking on the check symbol)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.