geost.base.Collection.select_by_condition#

Collection.select_by_condition(condition: Any, invert: bool = False)[source]#

Do a condition-based selection on the data table of the `Collection: return the rows in the data where the ‘condition’ evaluates to True, see examples below.

Parameters:
  • condition (list, pd.Series or array like) – Boolean array like object with locations at which the values will be preserved, dtype must be ‘bool’ and the length must correspond with the length of the data.

  • invert (bool, optional) – If True, the selection is inverted so rows that evaluate to False will be returned. The default is False.

Returns:

New instance containing only the rows obtained by the selection in the data table.

Return type:

Collection

Examples

Select rows in data that contain a specific value:

>>> data.select_by_condition(data["lith"] == "V")

Select rows in the data that contain a specific (part of) string or strings:

>>> boreholes.select_by_condition(boreholes["column"].str.contains("foo|bar"))

Select rows in data where column values are larger than:

>>> data.select_by_condition(data["column"] > 2)

Or select rows in the data based on multiple conditions:

>>> data.select_by_condition((data["column1"] > 2) & (data["column2] < 1))