Check if a pandas Series has at least one item greater than a value
You could use any method to check if that condition is True at least for the one value: In [36]: (s > 1).any() Out[36]: True
You could use any method to check if that condition is True at least for the one value: In [36]: (s > 1).any() Out[36]: True
To understand the “display class” you have to understand closures. The lambda you pass here is a closure, a special type of method that magically drags in state from the scope of the method it’s in and “closes around” it. …except of course that there’s no such thing as magic. All that state has to … Read more
some takes in a callback function where you can write your own logic to determine if an array contains some element which matches the conditions you wrote. includes does a generic equalTo comparison on every element and will return true if at least one element in the array is equal to the value to find.
Beside any and interface{} being type aliases — hence, equivalent in usage —, there is a practical difference between any as type parameter and any as regular function argument, as in your example. The difference is that in printAny[T any](foo T) the type of foo is not any/interface{}, but it’s T. And T after instantiation … Read more
No, in these variants are same: You can see – the execution plans are same too: postgres=# explain select * from foo1 where id in (select id from foo2); ┌──────────────────────────────────────────────────────────────────┐ │ QUERY PLAN │ ╞══════════════════════════════════════════════════════════════════╡ │ Hash Semi Join (cost=3.25..21.99 rows=100 width=4) │ │ Hash Cond: (foo1.id = foo2.id) │ │ -> Seq Scan on … Read more
SQL> SQL> — Use the ANY operator in a WHERE clause to compare a value with any of the values in a list. SQL> SQL> — You must place an =, <>, <, >, <=, or >= operator before ANY. SQL> SELECT * 2 FROM employee 3 WHERE salary > ANY (2000, 3000, 4000); For … Read more
OK, I figured I should have my take on it, instead of just posting comments. Sorry, this is going to be long, if you want the TL;DR skip to the end. As Randall Schulz said, here _ is a shorthand for an existential type. Namely, class Foo[T <: List[_]] is a shorthand for class Foo[T … Read more
These days you could actually use Array.prototype.some (specced in ES5) to get the same effect: array.some(function(item) { return notValid(item); });
How about: >>> any(isinstance(e, int) and e > 0 for e in [1,2,’joe’]) True It also works with all() of course: >>> all(isinstance(e, int) and e > 0 for e in [1,2,’joe’]) False
A Set<T> is an Iterable<T>, so iterating to the first element works: Set<T> things = …; return things.iterator().next(); Guava has a method to do this, though the above snippet is likely better.