geost.base.Collection.slice_by_values#

Collection.slice_by_values(column: str, values: str | Iterable | slice, invert: bool = False, inclusive: str = 'both')[source]#

Slice rows from data based on matching condition. E.g. only return rows with a certain lithology in the collection object.

Parameters:
  • column (str) – Name of column that contains categorical data to use when looking for values.

  • 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 slice a range of values, see example below.

  • invert (bool, optional) – If True, invert the slicing action, so remove layers with selected values instead of keeping them. 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 only the data that match the slicing condition in the data table. The data table contains only the rows that match the slicing condition, so not the entire data for the selected surveys. If you want to select entire surveys based on the presence of certain values, use the method select_by_values() instead.

Return type:

Collection

Examples

Return only rows in borehole data contain sand (“Z”) as lithology:

>>> boreholes.slice_by_values("lith", "Z")

If you want all the rows that may contain everything but sand, use the “invert” option:

>>> boreholes.slice_by_values("lith", "Z", invert=True)

In case of numerical values, use a slice object to slice data that contain a specific range of values. For example, to slice data that contain cone resistances (“qc”) between 15 and 20 MPa:

>>> data.slice_by_values("qc", slice(15, 20))