pandas_select.bool.Anywhere¶
-
class
Anywhere
(cond, columns=None)[source]¶ Filter rows where any column matches a condition.
- Parameters
cond (callable or boolean array-like) – Select labels where cond is True. If cond is a callable, it is computed on each column and should return a boolean array.
columns (optional) – Subset of columns on which to apply cond.
Examples
>>> df = pd.DataFrame({'A': [1, 1, 4], 'B': [2, -3, 1]}, index=["a", "b", "c"]) >>> df A B a 1 2 b 1 -3 c 4 1 >>> df.loc[Anywhere(lambda x : x % 2 == 0)] A B a 1 2 c 4 1 >>> df.loc[Anywhere(lambda x : x % 2 == 0, columns="A")] A B c 4 1