with numpy arrays, you can use some kind of inequality in the square bracket cut syntax:
>>>arr = numpy.array([1,2,3]) >>>arr[arr>=2] array([2, 3])
Is there any equivalent syntax in python regular data structures? I expected to get an error when I tried:
>>>lis = [1,2,3] >>>lis[lis > 2] 2
but instead of excluding some type, I get a return value of 2, which does not make much sense.
ps I could not find documentation for this syntax at all, so if someone could point me to numpy for it and for regular python (if it exists), that would be great.
source share