Condition(rule, columns=None, mode=ColumnMatch.ANY)
Source¶
A rule applied to one or several columns of a Table, used by Filter.
A missing value only satisfies IsMissing.
Added in version 0.1.0
Parameters:
-
rule(Rule)A
Rule, such asndp.Greater(100)orndp.IsIn(["Paris"]): seeRulefor every rule. -
columns(list[str] | None, default:None)The names of the columns the rule applies to, every column when omitted. The condition keeps its own copy of the list.
-
mode(ColumnMatch, default:ColumnMatch.ANY)Whether one column satisfying the rule is enough,
ColumnMatch.ANYby default, or every column must,ColumnMatch.ALL.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
EmptyListErrorWhen
columnsis an empty list. -
InvalidColumnNameErrorWhen a column name is an empty text.
-
DuplicateColumnErrorWhen a column name appears twice.
Examples:
import numdaplot as ndp
prices = ndp.Array.from_list([120.0, 80.0, 90.0])
costs = ndp.Array.from_list([70.0, 60.0, 110.0])
sales = ndp.Table.from_arrays({"price": prices, "cost": costs})
above_hundred = ndp.Condition(rule=ndp.Greater(100), columns=["price", "cost"])
sales.filter(ndp.Filter(conditions=[above_hundred]))
# price cost
# FLOAT64 FLOAT64
# 0 120.0 70.0
# 1 90.0 110.0