geost.base.Collection.select_by_values#
- Collection.select_by_values(column: str, values: str | Iterable | slice, how: str = 'or', invert: bool = False, inclusive: str = 'both')[source]#
Select data based on the presence of values in a given column. Can be used for example to select boreholes that contain peat in the lithology column.
- Parameters:
column (str) – Name of the column to look for the selection values in.
values (str | Iterable | slice) – Value or array-like set of values to look for in the column. In case of numerical values, a slice can be used to select data that contain a specific range of values, see example below.
how ({"and", "or"}, optional) – Either “and” or “or”, only used when multiple categorical values are provided. “and” requires all selection values to be present in the column for selection. “or” will select the data if any one of the values are found in the column. The default is “and”.
invert (bool, optional) – If True, the selection is inverted so that data that does not match the selection criteria is returned instead. The default is False.
inclusive ({"both", "neither", "left", "right"}, optional) – When a slice is used for selection to include boundaries or not. The default is “both”.
- Returns:
New Collection instance containing the all data from the selection result. The data table contains the entire data for the selected surveys, so not only the rows that match the selection. If that is desired, use the method
slice_by_values()instead.- Return type:
Examples
To select data where both clay (“K”) and peat (“V”) are present at the same time, use “and” as a selection method:
>>> data.select_by_values("lith", ["V", "K"], how="and")
To select data that can have one, or both lithologies, use or as the selection method:
>>> data.select_by_values("lith", ["V", "K"], how="or")
In case of numerical values, use a slice to select data that contain a specific range of values. For example, to select data that contain cone resistances (“qc”) between 15 and 20 MPa:
>>> data.select_by_values("qc", slice(15, 20))