DB_Table.filter
filtercolumnfilter on_problems
Group: Selections
Aliases: filter rows, where
Documentation
Selects only the rows of this table that correspond to True values of filter.
Arguments
column: The column to use for filtering. Can be a column name, index or theColumnobject itself.filter: The filter to apply to the column. It can either be an instance ofFilter_Conditionor a predicate taking a cell value and returning a boolean value indicating whether the corresponding row should be kept or not.on_problems: Specifies how to handle if a non-fatal problem occurs, attaching a warning by default.
Examples
Get people older than 30.
people.filter "Age" (Greater 30)
Filter people between 30 and 40.
people.filter "Age" (Between 30 40)
Select rows where more than 50% of the stock is sold.
table.filter "sold_stock" (Greater (table.at "total_stock" / 2))
Select people celebrating a jubilee.
people.filter "age" (age -> (age%10 == 0))
Errors
- If a column name cannot be found, a
No_Such_Columndataflow error is raised. - If a column index is invalid, an
Index_Out_Of_Boundsdataflow error is raised. - If the column is an invalid type for the filter, an
Invalid_Value_Typedataflow error is raised. - Additionally, the following problems may be reported according to the
on_problemssetting:- If filtering by equality on a floating-point column,
a
Floating_Point_Equality.
- If filtering by equality on a floating-point column,
a