[python] How do I select elements of an array given condition?